
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>资源 · 《Terraform入门教程》</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="大可不加冰">
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-prism/prism-vsc-dark-plus.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-image-captions/image-captions.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="3.7.数据源.html" />
    
    
    <link rel="prev" href="3.5.局部值.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                        <b>1.1.</b>
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="1.Terraform初步体验.html">
            
                <a href="1.Terraform初步体验.html">
            
                    
                        <b>1.2.</b>
                    
                    Terraform 初步体验
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                        <b>1.3.</b>
                    
                    Terraform基础概念
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="2.1.Terraform基础概念——Provider.html">
            
                <a href="2.1.Terraform基础概念——Provider.html">
            
                    
                        <b>1.3.1.</b>
                    
                    Provider
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="2.2.Terraform基础概念——状态管理.html">
            
                <a href="2.2.Terraform基础概念——状态管理.html">
            
                    
                        <b>1.3.2.</b>
                    
                    状态管理
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="3.Terraform代码的书写.html">
            
                <a href="3.Terraform代码的书写.html">
            
                    
                        <b>1.4.</b>
                    
                    Terraform 代码的书写
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="3.1.类型.html">
            
                <a href="3.1.类型.html">
            
                    
                        <b>1.4.1.</b>
                    
                    类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="3.2.配置语法.html">
            
                <a href="3.2.配置语法.html">
            
                    
                        <b>1.4.2.</b>
                    
                    配置语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="3.3.输入变量.html">
            
                <a href="3.3.输入变量.html">
            
                    
                        <b>1.4.3.</b>
                    
                    输入变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="3.4.输出值.html">
            
                <a href="3.4.输出值.html">
            
                    
                        <b>1.4.4.</b>
                    
                    输出值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="3.5.局部值.html">
            
                <a href="3.5.局部值.html">
            
                    
                        <b>1.4.5.</b>
                    
                    局部值
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.6" data-path="3.6.资源.html">
            
                <a href="3.6.资源.html">
            
                    
                        <b>1.4.6.</b>
                    
                    资源
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="3.7.数据源.html">
            
                <a href="3.7.数据源.html">
            
                    
                        <b>1.4.7.</b>
                    
                    数据源
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="3.8.表达式.html">
            
                <a href="3.8.表达式.html">
            
                    
                        <b>1.4.8.</b>
                    
                    表达式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="3.9.重载文件.html">
            
                <a href="3.9.重载文件.html">
            
                    
                        <b>1.4.9.</b>
                    
                    重载文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="3.10.代码风格规范.html">
            
                <a href="3.10.代码风格规范.html">
            
                    
                        <b>1.4.10.</b>
                    
                    代码风格规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.11" data-path="3.11.checks.html">
            
                <a href="3.11.checks.html">
            
                    
                        <b>1.4.11.</b>
                    
                    Checks
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="4.Terraform模块.html">
            
                <a href="4.Terraform模块.html">
            
                    
                        <b>1.5.</b>
                    
                    Terraform 模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="4.1.创建模块.html">
            
                <a href="4.1.创建模块.html">
            
                    
                        <b>1.5.1.</b>
                    
                    创建模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="4.2.使用模块.html">
            
                <a href="4.2.使用模块.html">
            
                    
                        <b>1.5.2.</b>
                    
                    使用模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="4.3.模块元参数.html">
            
                <a href="4.3.模块元参数.html">
            
                    
                        <b>1.5.3.</b>
                    
                    模块元参数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="4.4.重构.html">
            
                <a href="4.4.重构.html">
            
                    
                        <b>1.5.4.</b>
                    
                    重构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="4.5.设计新模块的模式.html">
            
                <a href="4.5.设计新模块的模式.html">
            
                    
                        <b>1.5.5.</b>
                    
                    设计新模块的模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="5.Terraform命令行.html">
            
                <a href="5.Terraform命令行.html">
            
                    
                        <b>1.6.</b>
                    
                    Terraform 命令行
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="5.1.命令行配置文件.html">
            
                <a href="5.1.命令行配置文件.html">
            
                    
                        <b>1.6.1.</b>
                    
                    命令行配置文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="5.2.环境变量.html">
            
                <a href="5.2.环境变量.html">
            
                    
                        <b>1.6.2.</b>
                    
                    环境变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="5.3.资源地址.html">
            
                <a href="5.3.资源地址.html">
            
                    
                        <b>1.6.3.</b>
                    
                    资源地址
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="5.4.apply.html">
            
                <a href="5.4.apply.html">
            
                    
                        <b>1.6.4.</b>
                    
                    apply
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="5.5.console.html">
            
                <a href="5.5.console.html">
            
                    
                        <b>1.6.5.</b>
                    
                    console
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="5.6.destroy.html">
            
                <a href="5.6.destroy.html">
            
                    
                        <b>1.6.6.</b>
                    
                    destroy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="5.7.fmt.html">
            
                <a href="5.7.fmt.html">
            
                    
                        <b>1.6.7.</b>
                    
                    fmt
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="5.8.force-unlock.html">
            
                <a href="5.8.force-unlock.html">
            
                    
                        <b>1.6.8.</b>
                    
                    force-unlock
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="5.9.get.html">
            
                <a href="5.9.get.html">
            
                    
                        <b>1.6.9.</b>
                    
                    get
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="5.10.graph.html">
            
                <a href="5.10.graph.html">
            
                    
                        <b>1.6.10.</b>
                    
                    graph
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.11" data-path="5.11.import.html">
            
                <a href="5.11.import.html">
            
                    
                        <b>1.6.11.</b>
                    
                    import
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.12" data-path="5.12.init.html">
            
                <a href="5.12.init.html">
            
                    
                        <b>1.6.12.</b>
                    
                    init
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.13" data-path="5.13.output.html">
            
                <a href="5.13.output.html">
            
                    
                        <b>1.6.13.</b>
                    
                    output
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.14" data-path="5.14.plan.html">
            
                <a href="5.14.plan.html">
            
                    
                        <b>1.6.14.</b>
                    
                    plan
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.15" data-path="5.15.providers.html">
            
                <a href="5.15.providers.html">
            
                    
                        <b>1.6.15.</b>
                    
                    providers
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.15.1" data-path="5.15.1.mirror.html">
            
                <a href="5.15.1.mirror.html">
            
                    
                        <b>1.6.15.1.</b>
                    
                    mirror
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.15.2" data-path="5.15.2.schema.html">
            
                <a href="5.15.2.schema.html">
            
                    
                        <b>1.6.15.2.</b>
                    
                    schema
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.16" data-path="5.16.refresh.html">
            
                <a href="5.16.refresh.html">
            
                    
                        <b>1.6.16.</b>
                    
                    refresh
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.17" data-path="5.17.show.html">
            
                <a href="5.17.show.html">
            
                    
                        <b>1.6.17.</b>
                    
                    show
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18" data-path="5.18.state.html">
            
                <a href="5.18.state.html">
            
                    
                        <b>1.6.18.</b>
                    
                    state
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.18.1" data-path="5.18.1.list.html">
            
                <a href="5.18.1.list.html">
            
                    
                        <b>1.6.18.1.</b>
                    
                    list
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.2" data-path="5.18.2.mv.html">
            
                <a href="5.18.2.mv.html">
            
                    
                        <b>1.6.18.2.</b>
                    
                    mv
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.3" data-path="5.18.3.pull.html">
            
                <a href="5.18.3.pull.html">
            
                    
                        <b>1.6.18.3.</b>
                    
                    pull
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.4" data-path="5.18.4.push.html">
            
                <a href="5.18.4.push.html">
            
                    
                        <b>1.6.18.4.</b>
                    
                    push
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.5" data-path="5.18.5.replace-provider.html">
            
                <a href="5.18.5.replace-provider.html">
            
                    
                        <b>1.6.18.5.</b>
                    
                    replace-provider
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.6" data-path="5.18.6.rm.html">
            
                <a href="5.18.6.rm.html">
            
                    
                        <b>1.6.18.6.</b>
                    
                    rm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.7" data-path="5.18.7.show.html">
            
                <a href="5.18.7.show.html">
            
                    
                        <b>1.6.18.7.</b>
                    
                    show
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.19" data-path="5.19.taint.html">
            
                <a href="5.19.taint.html">
            
                    
                        <b>1.6.19.</b>
                    
                    taint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.20" data-path="5.20.validate.html">
            
                <a href="5.20.validate.html">
            
                    
                        <b>1.6.20.</b>
                    
                    validate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.21" data-path="5.21.untaint.html">
            
                <a href="5.21.untaint.html">
            
                    
                        <b>1.6.21.</b>
                    
                    untaint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22" data-path="5.22.workspace.html">
            
                <a href="5.22.workspace.html">
            
                    
                        <b>1.6.22.</b>
                    
                    workspace
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.22.1" data-path="5.22.1.list.html">
            
                <a href="5.22.1.list.html">
            
                    
                        <b>1.6.22.1.</b>
                    
                    list
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22.2" data-path="5.22.2.select.html">
            
                <a href="5.22.2.select.html">
            
                    
                        <b>1.6.22.2.</b>
                    
                    select
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22.3" data-path="5.22.3.new.html">
            
                <a href="5.22.3.new.html">
            
                    
                        <b>1.6.22.3.</b>
                    
                    new
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22.4" data-path="5.22.4.delete.html">
            
                <a href="5.22.4.delete.html">
            
                    
                        <b>1.6.22.4.</b>
                    
                    delete
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22.5" data-path="5.22.5.show.html">
            
                <a href="5.22.5.show.html">
            
                    
                        <b>1.6.22.5.</b>
                    
                    show
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="6.test.html">
            
                <a href="6.test.html">
            
                    
                        <b>1.7.</b>
                    
                    Terraform Test
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="7.Aha——会心一击.html">
            
                <a href="7.Aha——会心一击.html">
            
                    
                        <b>1.8.</b>
                    
                    Aha——会心一击
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="7.1.有条件创建.html">
            
                <a href="7.1.有条件创建.html">
            
                    
                        <b>1.8.1.</b>
                    
                    有条件创建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="7.2.依赖反转.html">
            
                <a href="7.2.依赖反转.html">
            
                    
                        <b>1.8.2.</b>
                    
                    依赖反转
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="7.3.多可用区分布.html">
            
                <a href="7.3.多可用区分布.html">
            
                    
                        <b>1.8.3.</b>
                    
                    多可用区分布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="7.4.provisioner与user_data.html">
            
                <a href="7.4.provisioner与user_data.html">
            
                    
                        <b>1.8.4.</b>
                    
                    provisioner与user_data
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="7.5.destroy-provisioner中使用变量.html">
            
                <a href="7.5.destroy-provisioner中使用变量.html">
            
                    
                        <b>1.8.5.</b>
                    
                    destroy-provisioner中使用变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="7.6.利用null_resource的triggers触发其他资源更新.html">
            
                <a href="7.6.利用null_resource的triggers触发其他资源更新.html">
            
                    
                        <b>1.8.6.</b>
                    
                    利用null_resource的triggers触发其他资源更新
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="7.7.利用null_resource搭配replace_triggered_by更新无法读取的属性.html">
            
                <a href="7.7.利用null_resource搭配replace_triggered_by更新无法读取的属性.html">
            
                    
                        <b>1.8.7.</b>
                    
                    利用 null_resource 搭配 replace_triggered_by 更新无法从服务端读取内容的属性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="7.8.创建资源的条件依赖另一个资源的输出时怎么办.html">
            
                <a href="7.8.创建资源的条件依赖另一个资源的输出时怎么办.html">
            
                    
                        <b>1.8.8.</b>
                    
                    创建资源的条件依赖另一个资源的输出时怎么办
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="7.9.利用create_before_destroy调整资源update执行的顺序.html">
            
                <a href="7.9.利用create_before_destroy调整资源update执行的顺序.html">
            
                    
                        <b>1.8.9.</b>
                    
                    利用 create_before_destroy 调整资源 Update 的执行顺序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.10" data-path="7.10.terraform与自动化.html">
            
                <a href="7.10.terraform与自动化.html">
            
                    
                        <b>1.8.10.</b>
                    
                    Terraform 与自动化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="8.CloudPosse最佳实践.html">
            
                <a href="8.CloudPosse最佳实践.html">
            
                    
                        <b>1.9.</b>
                    
                    来自CloudPosse的Terraform最佳实践
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="9.后记.html">
            
                <a href="9.后记.html">
            
                    
                        <b>1.10.</b>
                    
                    后记
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >资源</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#&#x8D44;&#x6E90;"><b>1.4.6.1. </b>&#x8D44;&#x6E90;</a></li><ul><li><span class="title-icon "></span><a href="#&#x8D44;&#x6E90;&#x8BED;&#x6CD5;"><b>1.4.6.1.1. </b>&#x8D44;&#x6E90;&#x8BED;&#x6CD5;</a></li><li><span class="title-icon "></span><a href="#&#x8D44;&#x6E90;&#x7C7B;&#x578B;"><b>1.4.6.1.2. </b>&#x8D44;&#x6E90;&#x7C7B;&#x578B;</a></li><ul><li><span class="title-icon "></span><a href="#providers"><b>1.4.6.1.2.1. </b>Providers</a></li><li><span class="title-icon "></span><a href="#&#x8D44;&#x6E90;&#x53C2;&#x6570;"><b>1.4.6.1.2.2. </b>&#x8D44;&#x6E90;&#x53C2;&#x6570;</a></li><li><span class="title-icon "></span><a href="#&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x7684;&#x6587;&#x6863;"><b>1.4.6.1.2.3. </b>&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x7684;&#x6587;&#x6863;</a></li></ul><li><span class="title-icon "></span><a href="#&#x8D44;&#x6E90;&#x7684;&#x884C;&#x4E3A;"><b>1.4.6.1.3. </b>&#x8D44;&#x6E90;&#x7684;&#x884C;&#x4E3A;</a></li><li><span class="title-icon "></span><a href="#&#x8BBF;&#x95EE;&#x8D44;&#x6E90;&#x8F93;&#x51FA;&#x5C5E;&#x6027;"><b>1.4.6.1.4. </b>&#x8BBF;&#x95EE;&#x8D44;&#x6E90;&#x8F93;&#x51FA;&#x5C5E;&#x6027;</a></li><ul><li><span class="title-icon "></span><a href="#&#x654F;&#x611F;&#x7684;&#x8D44;&#x6E90;&#x5C5E;&#x6027;"><b>1.4.6.1.4.1. </b>&#x654F;&#x611F;&#x7684;&#x8D44;&#x6E90;&#x5C5E;&#x6027;</a></li></ul><li><span class="title-icon "></span><a href="#&#x8D44;&#x6E90;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;"><b>1.4.6.1.5. </b>&#x8D44;&#x6E90;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;</a></li><li><span class="title-icon "></span><a href="#&#x5143;&#x53C2;&#x6570;"><b>1.4.6.1.6. </b>&#x5143;&#x53C2;&#x6570;</a></li><ul><li><span class="title-icon "></span><a href="#dependson"><b>1.4.6.1.6.1. </b>depends_on</a></li><li><span class="title-icon "></span><a href="#count"><b>1.4.6.1.6.2. </b>count</a></li><li><span class="title-icon "></span><a href="#foreach"><b>1.4.6.1.6.3. </b>for_each</a></li><li><span class="title-icon "></span><a href="#&#x5728;-foreach-&#x548C;-count-&#x4E4B;&#x95F4;&#x9009;&#x62E9;"><b>1.4.6.1.6.4. </b>&#x5728; for_each &#x548C; count &#x4E4B;&#x95F4;&#x9009;&#x62E9;</a></li><li><span class="title-icon "></span><a href="#provider"><b>1.4.6.1.6.5. </b>provider</a></li><li><span class="title-icon "></span><a href="#lifecycle"><b>1.4.6.1.6.6. </b>lifecycle</a></li><li><span class="title-icon "></span><a href="#precondition-&#x4E0E;-postcondition"><b>1.4.6.1.6.7. </b>Precondition &#x4E0E; Postcondition</a></li><li><span class="title-icon "></span><a href="#provisioner-&#x548C;-connection"><b>1.4.6.1.6.8. </b>provisioner &#x548C; connection</a></li></ul><li><span class="title-icon "></span><a href="#&#x521B;&#x5EFA;&#x65F6;&#x9884;&#x7F6E;&#x5668;"><b>1.4.6.1.7. </b>&#x521B;&#x5EFA;&#x65F6;&#x9884;&#x7F6E;&#x5668;</a></li><li><span class="title-icon "></span><a href="#&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;"><b>1.4.6.1.8. </b>&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;</a></li><li><span class="title-icon "></span><a href="#&#x9884;&#x7F6E;&#x5668;&#x5931;&#x8D25;&#x884C;&#x4E3A;"><b>1.4.6.1.9. </b>&#x9884;&#x7F6E;&#x5668;&#x5931;&#x8D25;&#x884C;&#x4E3A;</a></li><li><span class="title-icon "></span><a href="#&#x672C;&#x5730;&#x8D44;&#x6E90;"><b>1.4.6.1.10. </b>&#x672C;&#x5730;&#x8D44;&#x6E90;</a></li><li><span class="title-icon "></span><a href="#&#x64CD;&#x4F5C;&#x8D85;&#x65F6;&#x8BBE;&#x7F6E;"><b>1.4.6.1.11. </b>&#x64CD;&#x4F5C;&#x8D85;&#x65F6;&#x8BBE;&#x7F6E;</a></li></ul></ul></div><a href="#&#x8D44;&#x6E90;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="&#x8D44;&#x6E90;"><a name="&#x8D44;&#x6E90;" class="anchor-navigation-ex-anchor" href="#&#x8D44;&#x6E90;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1. &#x8D44;&#x6E90;</h1>
<p>&#x8D44;&#x6E90;&#x662F; Terraform &#x6700;&#x91CD;&#x8981;&#x7684;&#x7EC4;&#x6210;&#x90E8;&#x5206;&#xFF0C;&#x800C;&#x672C;&#x8282;&#x4EA6;&#x662F;&#x672C;&#x6559;&#x7A0B;&#x6700;&#x91CD;&#x8981;&#x7684;&#x4E00;&#x8282;&#x3002;&#x8D44;&#x6E90;&#x901A;&#x8FC7; <code>resource</code> &#x5757;&#x6765;&#x5B9A;&#x4E49;&#xFF0C;&#x4E00;&#x4E2A; <code>resource</code> &#x53EF;&#x4EE5;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#xFF0C;&#x4F8B;&#x5982; VPC&#x3001;&#x865A;&#x62DF;&#x673A;&#xFF0C;&#x6216;&#x662F; DNS &#x8BB0;&#x5F55;&#x3001;Consul &#x7684;&#x952E;&#x503C;&#x5BF9;&#x6570;&#x636E;&#x7B49;&#x3002;</p>
<h2 id="&#x8D44;&#x6E90;&#x8BED;&#x6CD5;"><a name="&#x8D44;&#x6E90;&#x8BED;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x8D44;&#x6E90;&#x8BED;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.1. &#x8D44;&#x6E90;&#x8BED;&#x6CD5;</h2>
<p>&#x8D44;&#x6E90;&#x901A;&#x8FC7; <code>resource</code> &#x5757;&#x5B9A;&#x4E49;&#xFF0C;&#x6211;&#x4EEC;&#x9996;&#x5148;&#x8BB2;&#x89E3;&#x901A;&#x8FC7; <code>resource</code> &#x5757;&#x5B9A;&#x4E49;&#x5355;&#x4E2A;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x7684;&#x573A;&#x666F;&#x3002;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_vpc&quot;</span></span> <span class="token string">&quot;main&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">cidr_block</span> <span class="token punctuation">=</span> var.base_cidr_block
<span class="token punctuation">}</span>

&lt;BLOCK TYPE&gt; <span class="token string">&quot;&lt;BLOCK LABEL&gt;&quot;</span> <span class="token string">&quot;&lt;BLOCK LABEL&gt;&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># Block body</span>
  &lt;IDENTIFIER&gt; <span class="token punctuation">=</span> &lt;EXPRESSION&gt; <span class="token comment"># Argument</span>
<span class="token punctuation">}</span>
</code></pre>
<ul>
<li><strong>&#x5757;</strong> &#x662F;&#x5176;&#x4ED6;&#x5185;&#x5BB9;&#x7684;&#x5BB9;&#x5668;&#xFF0C;&#x901A;&#x5E38;&#x4EE3;&#x8868;&#x67D0;&#x79CD;&#x5BF9;&#x8C61;&#x7684;&#x914D;&#x7F6E;&#xFF0C;&#x6BD4;&#x5982;&#x8D44;&#x6E90;&#x3002;&#x5757;&#x6709;&#x4E00;&#x4E2A;&#x5757;&#x7C7B;&#x578B;&#xFF0C;&#x53EF;&#x4EE5;&#x6709;&#x96F6;&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x6807;&#x7B7E;&#xFF0C;&#x6709;&#x4E00;&#x4E2A;&#x5305;&#x542B;&#x4EFB;&#x610F;&#x6570;&#x91CF;&#x7684;&#x53C2;&#x6570;&#x548C;&#x5D4C;&#x5957;&#x5757;&#x7684;&#x5757;&#x4F53;&#x3002;Terraform &#x7684;&#x5927;&#x90E8;&#x5206;&#x529F;&#x80FD;&#x90FD;&#x662F;&#x7531;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x9876;&#x7EA7;&#x5757;&#x63A7;&#x5236;&#x7684;&#x3002;</li>
<li><strong>&#x53C2;&#x6570;</strong> &#x4E3A;&#x4E00;&#x4E2A;&#x540D;&#x79F0;&#x8D4B;&#x503C;&#x3002;&#x5B83;&#x4EEC;&#x51FA;&#x73B0;&#x5728;&#x5757;&#x5185;&#x3002;</li>
<li><strong>&#x8868;&#x8FBE;&#x5F0F;</strong> &#x8868;&#x793A;&#x4E00;&#x4E2A;&#x503C;&#xFF0C;&#x53EF;&#x4EE5;&#x662F;&#x5B57;&#x9762;&#x91CF;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x662F;&#x5F15;&#x7528;&#x548C;&#x7EC4;&#x5408;&#x5176;&#x4ED6;&#x503C;&#x3002;&#x5B83;&#x4EEC;&#x51FA;&#x73B0;&#x5728;&#x53C2;&#x6570;&#x7684;&#x503C;&#x4E2D;&#xFF0C;&#x6216;&#x8005;&#x5728;&#x5176;&#x4ED6;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x3002;</li>
</ul>
<p>Terraform &#x662F;&#x4E00;&#x79CD;&#x58F0;&#x660E;&#x5F0F;&#x8BED;&#x8A00;&#xFF0C;&#x63CF;&#x8FF0;&#x7684;&#x662F;&#x4E00;&#x4E2A;&#x671F;&#x671B;&#x7684;&#x8D44;&#x6E90;&#x72B6;&#x6001;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x8FBE;&#x5230;&#x671F;&#x671B;&#x72B6;&#x6001;&#x6240;&#x9700;&#x8981;&#x7684;&#x6B65;&#x9AA4;&#x3002;&#x5757;&#x7684;&#x987A;&#x5E8F;&#x548C;&#x5B83;&#x4EEC;&#x6240;&#x5728;&#x7684;&#x6587;&#x4EF6;&#x901A;&#x5E38;&#x4E0D;&#x91CD;&#x8981;&#xFF1B;Terraform &#x53EA;&#x5728;&#x786E;&#x5B9A;&#x64CD;&#x4F5C;&#x987A;&#x5E8F;&#x65F6;&#x8003;&#x8651;&#x8D44;&#x6E90;&#x4E4B;&#x95F4;&#x7684;&#x9690;&#x5F0F;&#x548C;&#x663E;&#x5F0F;&#x5173;&#x7CFB;&#x3002;</p>
<p>&#x5728;&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x91CC;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;web&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">ami</span>           <span class="token punctuation">=</span> <span class="token string">&quot;ami-a1b2c3d4&quot;</span>
  <span class="token property">instance_type</span> <span class="token punctuation">=</span> <span class="token string">&quot;t2.micro&quot;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x7D27;&#x8DDF; <code>resource</code> &#x5173;&#x952E;&#x5B57;&#x7684;&#x662F;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#xFF0C;&#x5728;&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x91CC;&#x5C31;&#x662F; <code>aws_instance</code>&#x3002;&#x540E;&#x9762;&#x662F;&#x8D44;&#x6E90;&#x7684; Local Name&#xFF0C;&#x4F8B;&#x5B50;&#x91CC;&#x5C31;&#x662F; <code>web</code>&#x3002;Local Name &#x53EF;&#x4EE5;&#x5728;&#x540C;&#x4E00;&#x6A21;&#x5757;&#x5185;&#x7684;&#x4EE3;&#x7801;&#x91CC;&#x88AB;&#x7528;&#x6765;&#x5F15;&#x7528;&#x8BE5;&#x8D44;&#x6E90;&#xFF0C;&#x4F46;&#x7C7B;&#x578B;&#x52A0; Local Name &#x7684;&#x7EC4;&#x5408;&#x5728;&#x5F53;&#x524D;&#x6A21;&#x5757;&#x5185;&#x5FC5;&#x987B;&#x662F;&#x552F;&#x4E00;&#x7684;&#xFF0C;&#x4E0D;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x4E24;&#x4E2A;&#x8D44;&#x6E90; Local Name &#x53EF;&#x4EE5;&#x76F8;&#x540C;&#x3002;&#x968F;&#x540E;&#x7684;&#x82B1;&#x62EC;&#x53F7;&#x5185;&#x7684;&#x5185;&#x5BB9;&#x5C31;&#x662F;&#x5757;&#x4F53;&#xFF0C;&#x521B;&#x5EFA;&#x8D44;&#x6E90;&#x6240;&#x7528;&#x5230;&#x7684;&#x5404;&#x79CD;&#x53C2;&#x6570;&#x7684;&#x503C;&#x5C31;&#x5728;&#x5757;&#x4F53;&#x5185;&#x5B9A;&#x4E49;&#x3002;&#x4F8B;&#x5B50;&#x4E2D;&#x6211;&#x4EEC;&#x5B9A;&#x4E49;&#x4E86;&#x865A;&#x62DF;&#x673A;&#x6240;&#x4F7F;&#x7528;&#x7684;&#x955C;&#x50CF; id &#x4EE5;&#x53CA;&#x865A;&#x62DF;&#x673A;&#x7684;&#x5C3A;&#x5BF8;&#x3002;</p>
<p>&#x8BF7;&#x6CE8;&#x610F;&#xFF1A;&#x8D44;&#x6E90;&#x540D;&#x79F0;&#x5FC5;&#x987B;&#x4EE5;&#x5B57;&#x6BCD;&#x6216;&#x4E0B;&#x5212;&#x7EBF;&#x5F00;&#x5934;&#xFF0C;&#x53EA;&#x80FD;&#x5305;&#x542B;&#x5B57;&#x6BCD;&#x3001;&#x6570;&#x5B57;&#x3001;&#x4E0B;&#x5212;&#x7EBF;(<code>_</code>)&#x548C;&#x8FDE;&#x5B57;&#x7B26;(<code>-</code>)&#x3002;</p>
<h2 id="&#x8D44;&#x6E90;&#x7C7B;&#x578B;"><a name="&#x8D44;&#x6E90;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x8D44;&#x6E90;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.2. &#x8D44;&#x6E90;&#x7C7B;&#x578B;</h2>
<p>&#x6BCF;&#x4E2A;&#x8D44;&#x6E90;&#x90FD;&#x4E0E;&#x4E00;&#x4E2A;<em>&#x8D44;&#x6E90;&#x7C7B;&#x578B;</em>&#x76F8;&#x5173;&#x8054;&#xFF0C;<em>&#x8D44;&#x6E90;&#x7C7B;&#x578B;</em>&#x51B3;&#x5B9A;&#x4E86;&#x5B83;&#x7BA1;&#x7406;&#x7684;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x5BF9;&#x8C61;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x4EE5;&#x53CA;&#x8D44;&#x6E90;&#x652F;&#x6301;&#x7684;&#x53C2;&#x6570;&#x548C;&#x5176;&#x4ED6;&#x5C5E;&#x6027;&#x3002;</p>
<h3 id="providers"><a name="providers" class="anchor-navigation-ex-anchor" href="#providers"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.2.1. Providers</h3>
<p><a href="2.1.Terraform&#x57FA;&#x7840;&#x6982;&#x5FF5;&#x2014;&#x2014;Provider.html">Provider</a> &#x662F; Terraform &#x7528;&#x4EE5;&#x63D0;&#x4F9B;&#x4E00;&#x7EC4;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x7684;&#x63D2;&#x4EF6;&#x3002;&#x6BCF;&#x4E2A;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x90FD;&#x662F;&#x7531;&#x4E00;&#x4E2A; Provider &#x5B9E;&#x73B0;&#x7684;&#x3002;Provider &#x63D0;&#x4F9B;&#x4E86;&#x7BA1;&#x7406;&#x5355;&#x4E2A;&#x4E91;&#x6216;&#x672C;&#x5730;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x5E73;&#x53F0;&#x7684;&#x8D44;&#x6E90;&#x3002;Provider &#x4E0E; Terraform &#x5206;&#x5F00;&#x53D1;&#x5E03;&#xFF0C;&#x4F46; Terraform &#x53EF;&#x4EE5;&#x5728;&#x521D;&#x59CB;&#x5316;&#x5DE5;&#x4F5C;&#x76EE;&#x5F55;&#x65F6;&#x81EA;&#x52A8;&#x5B89;&#x88C5;&#x5927;&#x591A;&#x6570; Provider&#x3002;</p>
<p>&#x8981;&#x7BA1;&#x7406;&#x8D44;&#x6E90;&#xFF0C;Terraform &#x6A21;&#x5757;&#x5FC5;&#x987B;&#x6307;&#x5B9A;&#x6240;&#x9700;&#x7684; Provider&#x3002;&#x6709;&#x5173;&#x66F4;&#x591A;&#x4FE1;&#x606F;&#xFF0C;&#x8BF7;&#x53C2;&#x9605;<a href="2.1.Terraform&#x57FA;&#x7840;&#x6982;&#x5FF5;&#x2014;&#x2014;Provider.html#provider-&#x7684;&#x58F0;&#x660E;">Provider &#x7684;&#x58F0;&#x660E;</a>&#x3002;</p>
<p>&#x5927;&#x90E8;&#x5206; Provider &#x9700;&#x8981;&#x4E00;&#x4E9B;&#x914D;&#x7F6E;&#x6765;&#x8BBF;&#x95EE;&#x8FDC;&#x7A0B; API&#xFF0C;&#x8FD9;&#x4E9B;&#x914D;&#x7F6E;&#x662F;&#x5728;&#x6839;&#x6A21;&#x5757;&#x4E2D;&#x914D;&#x7F6E;&#x7684;&#x3002;&#x6709;&#x5173;&#x66F4;&#x591A;&#x4FE1;&#x606F;&#xFF0C;&#x8BF7;&#x53C2;&#x9605;<a href="2.1.Terraform&#x57FA;&#x7840;&#x6982;&#x5FF5;&#x2014;&#x2014;Provider.html#provider-&#x7684;&#x914D;&#x7F6E;">Provider &#x914D;&#x7F6E;</a>&#x3002;</p>
<p>&#x6839;&#x636E;&#x4E00;&#x4E2A; <code>resource</code> &#x5757;&#x7684;&#x7C7B;&#x578B;&#x540D;&#xFF0C;Terraform &#x901A;&#x5E38;&#x53EF;&#x4EE5;&#x786E;&#x5B9A;&#x4F7F;&#x7528;&#x54EA;&#x4E2A; Provider&#x3002;&#x6309;&#x7167;&#x7EA6;&#x5B9A;&#xFF0C;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x540D;&#x4EE5;&#x5176; Provider &#x7684;&#x9996;&#x9009; Local Name &#x5F00;&#x5934;&#x3002;&#x5F53;&#x4F7F;&#x7528;&#x4E00;&#x4E2A; Provider &#x7684;&#x591A;&#x4E2A;&#x914D;&#x7F6E;&#x6216;&#x975E;&#x9996;&#x9009;&#x7684;&#x672C;&#x5730; Provider &#x540D;&#x79F0;&#x65F6;&#xFF0C;&#x4F60;&#x5FC5;&#x987B;&#x4F7F;&#x7528; <a href="#provider">provider &#x5143;&#x53C2;&#x6570;</a> &#x6765;&#x624B;&#x52A8;&#x9009;&#x62E9;&#x4E00;&#x4E2A; Provider &#x914D;&#x7F6E;&#x3002;</p>
<h3 id="&#x8D44;&#x6E90;&#x53C2;&#x6570;"><a name="&#x8D44;&#x6E90;&#x53C2;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x8D44;&#x6E90;&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.2.2. &#x8D44;&#x6E90;&#x53C2;&#x6570;</h3>
<p>&#x4E0D;&#x540C;&#x8D44;&#x6E90;&#x5B9A;&#x4E49;&#x4E86;&#x4E0D;&#x540C;&#x7684;&#x53EF;&#x8D4B;&#x503C;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x5B98;&#x65B9;&#x6587;&#x6863;&#x5C06;&#x4E4B;&#x79F0;&#x4E3A;&#x53C2;&#x6570;(Argument)&#xFF0C;&#x6709;&#x4E9B;&#x53C2;&#x6570;&#x662F;&#x5FC5;&#x586B;&#x7684;&#xFF0C;&#x6709;&#x4E9B;&#x53C2;&#x6570;&#x662F;&#x53EF;&#x9009;&#x7684;&#x3002;&#x4F7F;&#x7528;&#x67D0;&#x9879;&#x8D44;&#x6E90;&#x524D;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x9605;&#x8BFB;&#x76F8;&#x5173;&#x6587;&#x6863;&#x4E86;&#x89E3;&#x53C2;&#x6570;&#x5217;&#x8868;&#x4EE5;&#x53CA;&#x4ED6;&#x4EEC;&#x7684;&#x542B;&#x4E49;&#x3001;&#x8D4B;&#x503C;&#x7684;&#x7EA6;&#x675F;&#x6761;&#x4EF6;&#x3002;</p>
<p>&#x53C2;&#x6570;&#x503C;&#x53EF;&#x4EE5;&#x662F;&#x7B80;&#x5355;&#x7684;&#x5B57;&#x9762;&#x91CF;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x662F;&#x4E00;&#x4E2A;&#x590D;&#x6742;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x3002;</p>
<h3 id="&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x7684;&#x6587;&#x6863;"><a name="&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x7684;&#x6587;&#x6863;" class="anchor-navigation-ex-anchor" href="#&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x7684;&#x6587;&#x6863;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.2.3. &#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x7684;&#x6587;&#x6863;</h3>
<p>&#x6BCF;&#x4E00;&#x4E2A; Terraform Provider &#x90FD;&#x6709;&#x81EA;&#x5DF1;&#x7684;&#x6587;&#x6863;&#xFF0C;&#x7528;&#x4EE5;&#x63CF;&#x8FF0;&#x5B83;&#x6240;&#x652F;&#x6301;&#x7684;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x79CD;&#x7C7B;&#xFF0C;&#x4EE5;&#x53CA;&#x6BCF;&#x79CD;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x6240;&#x652F;&#x6301;&#x7684;&#x5C5E;&#x6027;&#x5217;&#x8868;&#x3002;</p>
<p>&#x5927;&#x90E8;&#x5206;&#x516C;&#x5171;&#x7684; Provider &#x90FD;&#x662F;&#x901A;&#x8FC7; <a href="https://registry.terraform.io/browse/providers" target="_blank">Terraform Registry</a> &#x8FDE;&#x5E26;&#x6587;&#x6863;&#x4E00;&#x8D77;&#x53D1;&#x5E03;&#x7684;&#x3002;&#x5F53;&#x6211;&#x4EEC;&#x5728; Terraform Registry &#x7AD9;&#x70B9;&#x4E0A;&#x6D4F;&#x89C8;&#x4E00;&#x4E2A; Provider &#x7684;&#x9875;&#x9762;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x70B9;&#x51FB; &quot;Documentation&quot; &#x94FE;&#x63A5;&#x6765;&#x6D4F;&#x89C8;&#x76F8;&#x5173;&#x6587;&#x6863;&#x3002;Provider &#x7684;&#x6587;&#x6863;&#x90FD;&#x662F;&#x7248;&#x672C;&#x5316;&#x7684;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x9009;&#x62E9;&#x7279;&#x5B9A;&#x7248;&#x672C;&#x7684; Provider &#x6587;&#x6863;&#x3002;</p>
<p>&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;Provider &#x6587;&#x6863;&#x66FE;&#x7ECF;&#x662F;&#x76F4;&#x63A5;&#x6258;&#x7BA1;&#x5728; terraform.io &#x7AD9;&#x70B9;&#x4E0A;&#x7684;&#xFF0C;&#x4E5F;&#x5C31;&#x662F; Terraform &#x6838;&#x5FC3;&#x4E3B;&#x7AD9;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x6709;&#x4E9B; Provider &#x7684;&#x6587;&#x6863;&#x76EE;&#x524D;&#x4F9D;&#x7136;&#x6258;&#x7BA1;&#x5728;&#x90A3;&#x91CC;&#xFF0C;&#x4F46;&#x76EE;&#x524D; Terraform Registry &#x624D;&#x662F;&#x6240;&#x6709;&#x516C;&#x5171; Provider &#x6587;&#x6863;&#x7684;&#x4E3B;&#x7AD9;&#x3002;</p>
<h2 id="&#x8D44;&#x6E90;&#x7684;&#x884C;&#x4E3A;"><a name="&#x8D44;&#x6E90;&#x7684;&#x884C;&#x4E3A;" class="anchor-navigation-ex-anchor" href="#&#x8D44;&#x6E90;&#x7684;&#x884C;&#x4E3A;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.3. &#x8D44;&#x6E90;&#x7684;&#x884C;&#x4E3A;</h2>
<p>&#x4E00;&#x4E2A; <code>resource</code> &#x5757;&#x58F0;&#x660E;&#x4E86;&#x4F5C;&#x8005;&#x60F3;&#x8981;&#x521B;&#x5EFA;&#x7684;&#x4E00;&#x4E2A;&#x786E;&#x5207;&#x7684;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x4E14;&#x8BBE;&#x5B9A;&#x4E86;&#x5404;&#x9879;&#x5C5E;&#x6027;&#x7684;&#x503C;&#x3002;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x6B63;&#x5728;&#x7F16;&#x5199;&#x4E00;&#x4E2A;&#x65B0;&#x7684; Terraform &#x4EE3;&#x7801;&#x6587;&#x4EF6;&#xFF0C;&#x90A3;&#x4E48;&#x4EE3;&#x7801;&#x6240;&#x5B9A;&#x4E49;&#x7684;&#x8D44;&#x6E90;&#x4EC5;&#x4EC5;&#x53EA;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x5B58;&#x5728;&#xFF0C;&#x5E76;&#x6CA1;&#x6709;&#x4E0E;&#x4E4B;&#x5BF9;&#x5E94;&#x7684;&#x5B9E;&#x9645;&#x7684;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x8D44;&#x6E90;&#x5B58;&#x5728;&#x3002;</p>
<p>&#x5BF9;&#x4E00;&#x7EC4; Terraform &#x4EE3;&#x7801;&#x6267;&#x884C; <code>terraform apply</code> &#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x3001;&#x66F4;&#x65B0;&#x6216;&#x8005;&#x9500;&#x6BC1;&#x5B9E;&#x9645;&#x7684;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x5BF9;&#x8C61;&#xFF0C;Terraform &#x4F1A;&#x5236;&#x5B9A;&#x5E76;&#x6267;&#x884C;&#x53D8;&#x66F4;&#x8BA1;&#x5212;&#xFF0C;&#x4EE5;&#x4F7F;&#x5F97;&#x5B9E;&#x9645;&#x7684;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x7B26;&#x5408;&#x4EE3;&#x7801;&#x7684;&#x5B9A;&#x4E49;&#x3002;</p>
<p>&#x6BCF;&#x5F53; Terraform &#x6309;&#x7167;&#x4E00;&#x4E2A; <code>resource</code> &#x5757;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x5BF9;&#x8C61;&#xFF0C;&#x8FD9;&#x4E2A;&#x5B9E;&#x9645;&#x7684;&#x5BF9;&#x8C61;&#x7684; id &#x4F1A;&#x88AB;&#x4FDD;&#x5B58;&#x8FDB; Terraform &#x72B6;&#x6001;&#x4E2D;&#xFF0C;&#x4F7F;&#x5F97;&#x5C06;&#x6765; Terraform &#x53EF;&#x4EE5;&#x6839;&#x636E;&#x53D8;&#x66F4;&#x8BA1;&#x5212;&#x5BF9;&#x5B83;&#x8FDB;&#x884C;&#x66F4;&#x65B0;&#x6216;&#x662F;&#x9500;&#x6BC1;&#x64CD;&#x4F5C;&#x3002;&#x5982;&#x679C;&#x4E00;&#x4E2A; <code>resource</code> &#x5757;&#x63CF;&#x8FF0;&#x7684;&#x8D44;&#x6E90;&#x5728;&#x72B6;&#x6001;&#x6587;&#x4EF6;&#x4E2D;&#x5DF2;&#x6709;&#x8BB0;&#x5F55;&#xFF0C;&#x90A3;&#x4E48; Terraform &#x4F1A;&#x6BD4;&#x5BF9;&#x8BB0;&#x5F55;&#x7684;&#x72B6;&#x6001;&#x4E0E;&#x4EE3;&#x7801;&#x63CF;&#x8FF0;&#x7684;&#x72B6;&#x6001;&#xFF0C;&#x5982;&#x679C;&#x6709;&#x5FC5;&#x8981;&#xFF0C;Terraform &#x4F1A;&#x5236;&#x5B9A;&#x53D8;&#x66F4;&#x8BA1;&#x5212;&#x4EE5;&#x4F7F;&#x5F97;&#x8D44;&#x6E90;&#x72B6;&#x6001;&#x80FD;&#x591F;&#x7B26;&#x5408;&#x4EE3;&#x7801;&#x7684;&#x63CF;&#x8FF0;&#x3002;</p>
<p>&#x8FD9;&#x79CD;&#x884C;&#x4E3A;&#x9002;&#x7528;&#x4E8E;&#x6240;&#x6709;&#x8D44;&#x6E90;&#x800C;&#x65E0;&#x5173;&#x5176;&#x7C7B;&#x578B;&#x3002;&#x521B;&#x5EFA;&#x3001;&#x66F4;&#x65B0;&#x3001;&#x9500;&#x6BC1;&#x4E00;&#x4E2A;&#x8D44;&#x6E90;&#x7684;&#x7EC6;&#x8282;&#x4F1A;&#x6839;&#x636E;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x800C;&#x4E0D;&#x540C;&#xFF0C;&#x4F46;&#x662F;&#x8FD9;&#x4E2A;&#x884C;&#x4E3A;&#x89C4;&#x5219;&#x5374;&#x662F;&#x666E;&#x9002;&#x7684;&#x3002;</p>
<h2 id="&#x8BBF;&#x95EE;&#x8D44;&#x6E90;&#x8F93;&#x51FA;&#x5C5E;&#x6027;"><a name="&#x8BBF;&#x95EE;&#x8D44;&#x6E90;&#x8F93;&#x51FA;&#x5C5E;&#x6027;" class="anchor-navigation-ex-anchor" href="#&#x8BBF;&#x95EE;&#x8D44;&#x6E90;&#x8F93;&#x51FA;&#x5C5E;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.4. &#x8BBF;&#x95EE;&#x8D44;&#x6E90;&#x8F93;&#x51FA;&#x5C5E;&#x6027;</h2>
<p>&#x8D44;&#x6E90;&#x4E0D;&#x4F46;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x53C2;&#x6570;&#x4F20;&#x503C;&#xFF0C;&#x6210;&#x529F;&#x521B;&#x5EFA;&#x7684;&#x8D44;&#x6E90;&#x8FD8;&#x5BF9;&#x5916;&#x8F93;&#x51FA;&#x4E00;&#x4E9B;&#x901A;&#x8FC7;&#x8C03;&#x7528; API &#x624D;&#x80FD;&#x83B7;&#x5F97;&#x7684;&#x53EA;&#x8BFB;&#x6570;&#x636E;&#xFF0C;&#x7ECF;&#x5E38;&#x5305;&#x542B;&#x4E86;&#x4E00;&#x4E9B;&#x6211;&#x4EEC;&#x5728;&#x5B9E;&#x9645;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x8D44;&#x6E90;&#x4E4B;&#x524D;&#x65E0;&#x6CD5;&#x83B7;&#x77E5;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x6BD4;&#x5982;&#x4E91;&#x4E3B;&#x673A;&#x7684; id &#x7B49;&#xFF0C;&#x5B98;&#x65B9;&#x6587;&#x6863;&#x5C06;&#x4E4B;&#x79F0;&#x4E3A;&#x5C5E;&#x6027;(Attribute)&#x3002;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5728;&#x540C;&#x4E00;&#x6A21;&#x5757;&#x5185;&#x7684;&#x4EE3;&#x7801;&#x4E2D;&#x5F15;&#x7528;&#x8D44;&#x6E90;&#x7684;&#x5C5E;&#x6027;&#x6765;&#x521B;&#x5EFA;&#x5176;&#x4ED6;&#x8D44;&#x6E90;&#x6216;&#x662F;&#x8868;&#x8FBE;&#x5F0F;&#x3002;&#x5728;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x5F15;&#x7528;&#x8D44;&#x6E90;&#x5C5E;&#x6027;&#x7684;&#x8BED;&#x6CD5;&#x662F;<code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>RESOURCE</span> <span class="token attr-name">TYPE</span><span class="token punctuation">&gt;</span></span>.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>NAME</span><span class="token punctuation">&gt;</span></span>.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>ATTRIBUTE</span><span class="token punctuation">&gt;</span></span></code>&#x3002;</p>
<p>&#x8981;&#x83B7;&#x53D6;&#x4E00;&#x4E2A;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x8F93;&#x51FA;&#x7684;&#x5C5E;&#x6027;&#x5217;&#x8868;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x67E5;&#x9605;&#x5BF9;&#x5E94;&#x7684; Provider &#x6587;&#x6863;&#xFF0C;&#x4E00;&#x822C;&#x5728;&#x6587;&#x6863;&#x4E2D;&#x4F1A;&#x4E13;&#x95E8;&#x8BB0;&#x5F55;&#x8D44;&#x6E90;&#x7684;&#x8F93;&#x51FA;&#x5C5E;&#x6027;&#x5217;&#x8868;&#x3002;</p>
<h3 id="&#x654F;&#x611F;&#x7684;&#x8D44;&#x6E90;&#x5C5E;&#x6027;"><a name="&#x654F;&#x611F;&#x7684;&#x8D44;&#x6E90;&#x5C5E;&#x6027;" class="anchor-navigation-ex-anchor" href="#&#x654F;&#x611F;&#x7684;&#x8D44;&#x6E90;&#x5C5E;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.4.1. &#x654F;&#x611F;&#x7684;&#x8D44;&#x6E90;&#x5C5E;&#x6027;</h3>
<p>&#x5728;&#x4E3A;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x5B9A;&#x4E49;&#x67B6;&#x6784;&#x65F6;&#xFF0C;Provider &#x5F00;&#x53D1;&#x7740;&#x53EF;&#x4EE5;&#x5C06;&#x67D0;&#x4E9B;&#x5C5E;&#x6027;&#x6807;&#x8BB0;&#x4E3A; <code>sensitive</code>&#xFF0C;&#x5728;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;Terraform &#x5C06;&#x5728;&#x5C55;&#x793A;&#x6D89;&#x53CA;&#x8BE5;&#x5C5E;&#x6027;&#x7684;&#x8BA1;&#x5212;&#x65F6;&#x663E;&#x793A;&#x5360;&#x4F4D;&#x7B26;&#x6807;&#x8BB0;<code>(sensitive)</code> &#x800C;&#x4E0D;&#x662F;&#x5B9E;&#x9645;&#x503C;&#x3002;</p>
<p>&#x6807;&#x8BB0;&#x4E3A; <code>sensitive</code> &#x7684; Provider &#x5C5E;&#x6027;&#x7684;&#x884C;&#x4E3A;&#x7C7B;&#x4F3C;&#x4E8E;&#x58F0;&#x660E;&#x4E3A; <code>sensitive</code> &#x7684;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#xFF0C;Terraform &#x5C06;&#x9690;&#x85CF;&#x8BA1;&#x5212;&#x4E2D;&#x7684;&#x503C;&#xFF0C;&#x8FD8;&#x5C06;&#x9690;&#x85CF;&#x4ECE;&#x8BE5;&#x503C;&#x6D3E;&#x751F;&#x51FA;&#x7684;&#x4EFB;&#x4F55;&#x5176;&#x4ED6;&#x654F;&#x611F;&#x503C;&#x3002;&#x4F46;&#x662F;&#xFF0C;&#x8BE5;&#x884C;&#x4E3A;&#x5B58;&#x5728;&#x4E00;&#x4E9B;&#x9650;&#x5236;&#xFF0C;&#x5982; Terraform &#x53EF;&#x80FD;&#x66B4;&#x9732;&#x654F;&#x611F;&#x53D8;&#x91CF;&#x3002;</p>
<p>&#x5982;&#x679C;&#x4F7F;&#x7528;&#x8D44;&#x6E90;&#x5C5E;&#x6027;&#x4E2D;&#x7684;&#x654F;&#x611F;&#x503C;&#x4F5C;&#x4E3A;&#x8F93;&#x51FA;&#x503C;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;Terraform &#x5C06;&#x8981;&#x6C42;&#x5C06;&#x8F93;&#x51FA;&#x503C;&#x672C;&#x8EAB;&#x6807;&#x8BB0;&#x4E3A; <code>sensitive</code>&#xFF0C;&#x4EE5;&#x786E;&#x8BA4;&#x786E;&#x5B9E;&#x6253;&#x7B97;&#x5C06;&#x5176;&#x5BFC;&#x51FA;&#x3002;</p>
<p>Terraform &#x4ECD;&#x4F1A;&#x5728;&#x72B6;&#x6001;&#x4E2D;&#x8BB0;&#x5F55;&#x654F;&#x611F;&#x503C;&#xFF0C;&#x56E0;&#x6B64;&#x4EFB;&#x4F55;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x72B6;&#x6001;&#x6570;&#x636E;&#x7684;&#x4EBA;&#x90FD;&#x53EF;&#x4EE5;&#x4EE5;&#x660E;&#x6587;&#x5F62;&#x5F0F;&#x8BBF;&#x95EE;&#x654F;&#x611F;&#x503C;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF1A;Terraform &#x4ECE; v0.15 &#x5F00;&#x59CB;&#x5C06;&#x4ECE;&#x654F;&#x611F;&#x8D44;&#x6E90;&#x5C5E;&#x6027;&#x6D3E;&#x751F;&#x7684;&#x503C;&#x89C6;&#x4E3A;&#x654F;&#x611F;&#x503C;&#x672C;&#x8EAB;&#x3002;&#x65E9;&#x671F;&#x7248;&#x672C;&#x7684; Terraform &#x5C06;&#x9690;&#x85CF;&#x654F;&#x611F;&#x8D44;&#x6E90;&#x5C5E;&#x6027;&#x7684;&#x76F4;&#x63A5;&#x503C;&#xFF0C;&#x4F46;&#x4E0D;&#x4F1A;&#x81EA;&#x52A8;&#x9690;&#x85CF;&#x4ECE;&#x654F;&#x611F;&#x8D44;&#x6E90;&#x5C5E;&#x6027;&#x6D3E;&#x751F;&#x7684;&#x5176;&#x4ED6;&#x503C;&#x3002;</p>
<h2 id="&#x8D44;&#x6E90;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;"><a name="&#x8D44;&#x6E90;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;" class="anchor-navigation-ex-anchor" href="#&#x8D44;&#x6E90;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.5. &#x8D44;&#x6E90;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;</h2>
<p>&#x6211;&#x4EEC;&#x5728;&#x4ECB;&#x7ECD;&#x8F93;&#x51FA;&#x503C;&#x7684;<code>depends_on</code>&#x7684;&#x65F6;&#x5019;&#x5DF2;&#x7ECF;&#x7B80;&#x5355;&#x4ECB;&#x7ECD;&#x8FC7;&#x4E86;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x3002;&#x4E00;&#x822C;&#x6765;&#x8BF4;&#x5728; Terraform &#x4EE3;&#x7801;&#x5B9A;&#x4E49;&#x7684;&#x8D44;&#x6E90;&#x4E4B;&#x95F4;&#x4E0D;&#x4F1A;&#x6709;&#x7279;&#x5B9A;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#xFF0C;Terraform &#x53EF;&#x4EE5;&#x5E76;&#x884C;&#x5730;&#x5BF9;&#x591A;&#x4E2A;&#x65E0;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x7684;&#x8D44;&#x6E90;&#x6267;&#x884C;&#x53D8;&#x66F4;&#xFF0C;&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#x8FD9;&#x4E2A;&#x5E76;&#x884C;&#x5EA6;&#x662F; 10&#x3002;</p>
<p>&#x7136;&#x800C;&#xFF0C;&#x521B;&#x5EFA;&#x67D0;&#x4E9B;&#x8D44;&#x6E90;&#x6240;&#x9700;&#x8981;&#x7684;&#x4FE1;&#x606F;&#x4F9D;&#x8D56;&#x4E8E;&#x53E6;&#x4E00;&#x4E2A;&#x8D44;&#x6E90;&#x521B;&#x5EFA;&#x540E;&#x8F93;&#x51FA;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x53C8;&#x6216;&#x8005;&#x5FC5;&#x987B;&#x5728;&#x67D0;&#x4E9B;&#x8D44;&#x6E90;&#x6210;&#x529F;&#x521B;&#x5EFA;&#x540E;&#x624D;&#x53EF;&#x4EE5;&#x88AB;&#x521B;&#x5EFA;&#xFF0C;&#x8FD9;&#x65F6;&#x8D44;&#x6E90;&#x4E4B;&#x95F4;&#x5C31;&#x5B58;&#x5728;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x3002;</p>
<p>&#x5927;&#x90E8;&#x5206;&#x8D44;&#x6E90;&#x95F4;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x53EF;&#x4EE5;&#x88AB; Terraform &#x81EA;&#x52A8;&#x5904;&#x7406;&#xFF0C;Terraform &#x4F1A;&#x5206;&#x6790; <code>resource</code> &#x5757;&#x5185;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x6839;&#x636E;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5F15;&#x7528;&#x94FE;&#x6765;&#x786E;&#x5B9A;&#x8D44;&#x6E90;&#x4E4B;&#x95F4;&#x7684;&#x5F15;&#x7528;&#xFF0C;&#x8FDB;&#x800C;&#x8BA1;&#x7B97;&#x51FA;&#x8D44;&#x6E90;&#x5728;&#x521B;&#x5EFA;&#x3001;&#x66F4;&#x65B0;&#x3001;&#x9500;&#x6BC1;&#x65F6;&#x7684;&#x6267;&#x884C;&#x987A;&#x5E8F;&#x3002;&#x5927;&#x90E8;&#x5206;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x9700;&#x8981;&#x663E;&#x5F0F;&#x6307;&#x5B9A;&#x8D44;&#x6E90;&#x4E4B;&#x95F4;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x3002;</p>
<p>&#x7136;&#x800C;&#xFF0C;&#x6709;&#x65F6;&#x5019;&#x67D0;&#x4E9B;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x662F;&#x65E0;&#x6CD5;&#x4ECE;&#x4EE3;&#x7801;&#x4E2D;&#x63A8;&#x5BFC;&#x51FA;&#x6765;&#x7684;&#x3002;&#x4F8B;&#x5982;&#xFF0C;Terraform &#x5FC5;&#x987B;&#x8981;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x8BBF;&#x95EE;&#x63A7;&#x5236;&#x6743;&#x9650;&#x8D44;&#x6E90;&#xFF0C;&#x4EE5;&#x53CA;&#x53E6;&#x4E00;&#x4E2A;&#x9700;&#x8981;&#x8BE5;&#x6743;&#x9650;&#x624D;&#x80FD;&#x6210;&#x529F;&#x521B;&#x5EFA;&#x7684;&#x8D44;&#x6E90;&#x3002;&#x540E;&#x8005;&#x7684;&#x521B;&#x5EFA;&#x4F9D;&#x8D56;&#x4E8E;&#x524D;&#x8005;&#x7684;&#x6210;&#x529F;&#x521B;&#x5EFA;&#xFF0C;&#x7136;&#x800C;&#x8FD9;&#x79CD;&#x4F9D;&#x8D56;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x6CA1;&#x6709;&#x8868;&#x73B0;&#x4E3A;&#x6570;&#x636E;&#x5F15;&#x7528;&#x5173;&#x8054;&#xFF0C;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x7528; <code>depends_on</code> &#x6765;&#x663E;&#x5F0F;&#x58F0;&#x660E;&#x8FD9;&#x79CD;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x3002;</p>
<h2 id="&#x5143;&#x53C2;&#x6570;"><a name="&#x5143;&#x53C2;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x5143;&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.6. &#x5143;&#x53C2;&#x6570;</h2>
<p><code>resource</code> &#x5757;&#x652F;&#x6301;&#x51E0;&#x79CD;&#x5143;&#x53C2;&#x6570;&#x58F0;&#x660E;&#xFF0C;&#x8FD9;&#x4E9B;&#x5143;&#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x88AB;&#x58F0;&#x660E;&#x5728;&#x6240;&#x6709;&#x7C7B;&#x578B;&#x7684; <code>resource</code> &#x5757;&#x5185;&#xFF0C;&#x5B83;&#x4EEC;&#x5C06;&#x4F1A;&#x6539;&#x53D8;&#x8D44;&#x6E90;&#x7684;&#x884C;&#x4E3A;&#xFF1A;</p>
<ul>
<li><code>depends_on</code>&#xFF1A;&#x663E;&#x5F0F;&#x58F0;&#x660E;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;</li>
<li><code>count</code>&#xFF1A;&#x521B;&#x5EFA;&#x591A;&#x4E2A;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;</li>
<li><code>for_each</code>&#xFF1A;&#x8FED;&#x4EE3;&#x96C6;&#x5408;&#xFF0C;&#x4E3A;&#x96C6;&#x5408;&#x4E2D;&#x6BCF;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5BF9;&#x5E94;&#x7684;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;</li>
<li><code>provider</code>&#xFF1A;&#x6307;&#x5B9A;&#x975E;&#x9ED8;&#x8BA4; Provider &#x5B9E;&#x4F8B;</li>
<li><code>lifecycle</code>&#xFF1A;&#x81EA;&#x5B9A;&#x4E49;&#x8D44;&#x6E90;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x884C;&#x4E3A;</li>
<li><code>provisioner</code> &#x548C; <code>connection</code>&#xFF1A;&#x5728;&#x8D44;&#x6E90;&#x521B;&#x5EFA;&#x540E;&#x6267;&#x884C;&#x4E00;&#x4E9B;&#x989D;&#x5916;&#x7684;&#x64CD;&#x4F5C;</li>
</ul>
<p>&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x5C06;&#x9010;&#x4E00;&#x8BB2;&#x89E3;&#x4ED6;&#x4EEC;&#x7684;&#x7528;&#x6CD5;&#x3002;</p>
<h3 id="dependson"><a name="dependson" class="anchor-navigation-ex-anchor" href="#dependson"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.6.1. depends_on</h3>
<p>&#x4F7F;&#x7528; <code>depends_on</code> &#x53EF;&#x4EE5;&#x663E;&#x5F0F;&#x58F0;&#x660E;&#x8D44;&#x6E90;&#x4E4B;&#x95F4;&#x54EA;&#x4E9B; Terraform &#x65E0;&#x6CD5;&#x81EA;&#x52A8;&#x63A8;&#x5BFC;&#x51FA;&#x7684;&#x9690;&#x542B;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x3002;&#x53EA;&#x6709;&#x5F53;&#x8D44;&#x6E90;&#x95F4;&#x786E;&#x5B9E;&#x5B58;&#x5728;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#xFF0C;&#x4F46;&#x662F;&#x5F7C;&#x6B64;&#x95F4;&#x53C8;&#x6CA1;&#x6709;&#x6570;&#x636E;&#x5F15;&#x7528;&#x7684;&#x573A;&#x666F;&#x4E0B;&#x624D;&#x6709;&#x5FC5;&#x8981;&#x4F7F;&#x7528; <code>depends_on</code>&#x3002;</p>
<p>&#x4F7F;&#x7528; <code>depends_on</code> &#x7684;&#x4F8B;&#x5B50;&#x662F;&#x8FD9;&#x6837;&#x7684;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_iam_role&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">name</span> <span class="token punctuation">=</span> <span class="token string">&quot;example&quot;</span>

  <span class="token comment"># assume_role_policy is omitted for brevity in this example. See the</span>
  <span class="token comment"># documentation for aws_iam_role for a complete example.</span>
  <span class="token property">assume_role_policy</span> <span class="token punctuation">=</span> <span class="token string">&quot;...&quot;</span>
<span class="token punctuation">}</span>

<span class="token keyword">resource <span class="token type variable">&quot;aws_iam_instance_profile&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># Because this expression refers to the role, Terraform can infer</span>
  <span class="token comment"># automatically that the role must be created first.</span>
  <span class="token property">role</span> <span class="token punctuation">=</span> aws_iam_role.example.name
<span class="token punctuation">}</span>

<span class="token keyword">resource <span class="token type variable">&quot;aws_iam_role_policy&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">name</span>   <span class="token punctuation">=</span> <span class="token string">&quot;example&quot;</span>
  <span class="token property">role</span>   <span class="token punctuation">=</span> aws_iam_role.example.name
  <span class="token property">policy</span> <span class="token punctuation">=</span> jsonencode(<span class="token punctuation">{</span>
    <span class="token property">&quot;Statement&quot;</span> <span class="token punctuation">=</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
      <span class="token comment"># This policy allows software running on the EC2 instance to</span>
      <span class="token comment"># access the S3 API.</span>
      <span class="token property">&quot;Action&quot;</span> <span class="token punctuation">=</span> <span class="token string">&quot;s3:*&quot;</span>,
      <span class="token property">&quot;Effect&quot;</span> <span class="token punctuation">=</span> <span class="token string">&quot;Allow&quot;</span>,
    <span class="token punctuation">}</span><span class="token punctuation">]</span>,
  <span class="token punctuation">}</span>)
<span class="token punctuation">}</span>

<span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">ami</span>           <span class="token punctuation">=</span> <span class="token string">&quot;ami-a1b2c3d4&quot;</span>
  <span class="token property">instance_type</span> <span class="token punctuation">=</span> <span class="token string">&quot;t2.micro&quot;</span>

  <span class="token comment"># Terraform can infer from this that the instance profile must</span>
  <span class="token comment"># be created before the EC2 instance.</span>
  <span class="token property">iam_instance_profile</span> <span class="token punctuation">=</span> aws_iam_instance_profile.example

  <span class="token comment"># However, if software running in this EC2 instance needs access</span>
  <span class="token comment"># to the S3 API in order to boot properly, there is also a &quot;hidden&quot;</span>
  <span class="token comment"># dependency on the aws_iam_role_policy that Terraform cannot</span>
  <span class="token comment"># automatically infer, so it must be declared explicitly:</span>
  <span class="token property">depends_on</span> <span class="token punctuation">=</span> <span class="token punctuation">[</span>
    aws_iam_role_policy.example,
  <span class="token punctuation">]</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x6765;&#x5206;&#x6BB5;&#x89E3;&#x91CA;&#x4E00;&#x4E0B;&#x8FD9;&#x4E2A;&#x573A;&#x666F;&#xFF0C;&#x9996;&#x5148;&#x6211;&#x4EEC;&#x58F0;&#x660E;&#x4E86;&#x4E00;&#x4E2A; AWS IAM &#x89D2;&#x8272;&#xFF0C;&#x5C06;&#x89D2;&#x8272;&#x7ED1;&#x5B9A;&#x5728;&#x4E00;&#x4E2A;&#x4E3B;&#x673A;&#x5B9E;&#x4F8B;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E0A;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_iam_role&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">name</span> <span class="token punctuation">=</span> <span class="token string">&quot;example&quot;</span>

  <span class="token comment"># assume_role_policy is omitted for brevity in this example. See the</span>
  <span class="token comment"># documentation for aws_iam_role for a complete example.</span>
  <span class="token property">assume_role_policy</span> <span class="token punctuation">=</span> <span class="token string">&quot;...&quot;</span>
<span class="token punctuation">}</span>

<span class="token keyword">resource <span class="token type variable">&quot;aws_iam_instance_profile&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># Because this expression refers to the role, Terraform can infer</span>
  <span class="token comment"># automatically that the role must be created first.</span>
  <span class="token property">role</span> <span class="token punctuation">=</span> aws_iam_role.example.name
<span class="token punctuation">}</span>
</code></pre>
<p>&#x865A;&#x62DF;&#x673A;&#x7684;&#x58F0;&#x660E;&#x4EE3;&#x7801;&#x4E2D;&#x7684;&#x8FD9;&#x4E2A;&#x8D4B;&#x503C;&#x4F7F;&#x5F97; Terraform &#x80FD;&#x591F;&#x5224;&#x65AD;&#x51FA;&#x865A;&#x62DF;&#x673A;&#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x673A;&#x5B9E;&#x4F8B;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">ami</span>           <span class="token punctuation">=</span> <span class="token string">&quot;ami-a1b2c3d4&quot;</span>
  <span class="token property">instance_type</span> <span class="token punctuation">=</span> <span class="token string">&quot;t2.micro&quot;</span>

  <span class="token comment"># Terraform can infer from this that the instance profile must</span>
  <span class="token comment"># be created before the EC2 instance.</span>
  <span class="token property">iam_instance_profile</span> <span class="token punctuation">=</span> aws_iam_instance_profile.example
</code></pre>
<p>&#x81F3;&#x6B64;&#xFF0C;Terraform &#x89C4;&#x5212;&#x51FA;&#x7684;&#x521B;&#x5EFA;&#x987A;&#x5E8F;&#x662F; IAM &#x89D2;&#x8272; -&gt; &#x4E3B;&#x673A;&#x5B9E;&#x4F8B;&#x914D;&#x7F6E;&#x6587;&#x4EF6; -&gt; &#x4E3B;&#x673A;&#x5B9E;&#x4F8B;&#x3002;&#x4F46;&#x662F;&#x6211;&#x4EEC;&#x53C8;&#x4E3A;&#x8FD9;&#x4E2A; IAM &#x89D2;&#x8272;&#x6DFB;&#x52A0;&#x4E86;&#x5BF9; S3 &#x5B58;&#x50A8;&#x670D;&#x52A1;&#x7684;&#x5B8C;&#x5168;&#x63A7;&#x5236;&#x6743;&#x9650;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_iam_role_policy&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">name</span>   <span class="token punctuation">=</span> <span class="token string">&quot;example&quot;</span>
  <span class="token property">role</span>   <span class="token punctuation">=</span> aws_iam_role.example.name
  <span class="token property">policy</span> <span class="token punctuation">=</span> jsonencode(<span class="token punctuation">{</span>
    <span class="token property">&quot;Statement&quot;</span> <span class="token punctuation">=</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
      <span class="token comment"># This policy allows software running on the EC2 instance to</span>
      <span class="token comment"># access the S3 API.</span>
      <span class="token property">&quot;Action&quot;</span> <span class="token punctuation">=</span> <span class="token string">&quot;s3:*&quot;</span>,
      <span class="token property">&quot;Effect&quot;</span> <span class="token punctuation">=</span> <span class="token string">&quot;Allow&quot;</span>,
    <span class="token punctuation">}</span><span class="token punctuation">]</span>,
  <span class="token punctuation">}</span>)
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x865A;&#x62DF;&#x673A;&#x5B9E;&#x4F8B;&#x7531;&#x4E8E;&#x7ED1;&#x5B9A;&#x4E86;&#x4E3B;&#x673A;&#x5B9E;&#x4F8B;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x4ECE;&#x800C;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x62E5;&#x6709;&#x4E86;&#x4E00;&#x4E2A; IAM &#x89D2;&#x8272;&#xFF0C;&#x800C;&#x8FD9;&#x4E2A; IAM &#x89D2;&#x8272;&#x53C8;&#x88AB;&#x8D4B;&#x4E88;&#x4E86; S3 &#x7684;&#x6743;&#x9650;&#x3002;&#x4F46;&#x662F;&#x865A;&#x62DF;&#x673A;&#x5B9E;&#x4F8B;&#x7684;&#x58F0;&#x660E;&#x4EE3;&#x7801;&#x4E2D;&#x5E76;&#x6CA1;&#x6709;&#x5F15;&#x7528; S3 &#x6743;&#x9650;&#x7684;&#x4EFB;&#x4F55;&#x8F93;&#x51FA;&#x5C5E;&#x6027;&#xFF0C;&#x8FD9;&#x5C06;&#x5BFC;&#x81F4; Terraform &#x65E0;&#x6CD5;&#x7406;&#x89E3;&#x4ED6;&#x4EEC;&#x4E4B;&#x95F4;&#x5B58;&#x5728;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#xFF0C;&#x8FDB;&#x800C;&#x53EF;&#x80FD;&#x4F1A;&#x5E76;&#x884C;&#x5730;&#x521B;&#x5EFA;&#x4E24;&#x8005;&#xFF0C;&#x5982;&#x679C;&#x865A;&#x62DF;&#x673A;&#x5B9E;&#x4F8B;&#x88AB;&#x5148;&#x521B;&#x5EFA;&#x4E86;&#x51FA;&#x6765;&#xFF0C;&#x5185;&#x90E8;&#x7684;&#x7A0B;&#x5E8F;&#x5F00;&#x59CB;&#x8FD0;&#x884C;&#x65F6;&#xFF0C;&#x5B83;&#x6240;&#x9700;&#x8981;&#x7684; S3 &#x6743;&#x9650;&#x5374;&#x8FD8;&#x6CA1;&#x6709;&#x521B;&#x5EFA;&#x5B8C;&#x6210;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x5C06;&#x5BFC;&#x81F4;&#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#x9519;&#x8BEF;&#x3002;&#x4E3A;&#x4E86;&#x786E;&#x4FDD;&#x865A;&#x62DF;&#x673A;&#x521B;&#x5EFA;&#x65F6; S3 &#x6743;&#x9650;&#x4E00;&#x5B9A;&#x5DF2;&#x7ECF;&#x5B58;&#x5728;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x7528; <code>depends_on</code> &#x663E;&#x5F0F;&#x58F0;&#x660E;&#x5B83;&#x4EEC;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token comment"># However, if software running in this EC2 instance needs access</span>
  <span class="token comment"># to the S3 API in order to boot properly, there is also a &quot;hidden&quot;</span>
  <span class="token comment"># dependency on the aws_iam_role_policy that Terraform cannot</span>
  <span class="token comment"># automatically infer, so it must be declared explicitly:</span>
  <span class="token property">depends_on</span> <span class="token punctuation">=</span> <span class="token punctuation">[</span>
    aws_iam_role_policy.example,
  <span class="token punctuation">]</span>
</code></pre>
<p><code>depends_on</code> &#x7684;&#x8D4B;&#x503C;&#x5FC5;&#x987B;&#x662F;&#x5305;&#x542B;&#x540C;&#x4E00;&#x6A21;&#x5757;&#x5185;&#x58F0;&#x660E;&#x7684;&#x5176;&#x4ED6;&#x8D44;&#x6E90;&#x540D;&#x79F0;&#x7684;&#x5217;&#x8868;&#xFF0C;&#x4E0D;&#x5141;&#x8BB8;&#x5305;&#x542B;&#x5176;&#x4ED6;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x4F8B;&#x5982;&#x4E0D;&#x5141;&#x8BB8;&#x4F7F;&#x7528;&#x5176;&#x4ED6;&#x8D44;&#x6E90;&#x7684;&#x8F93;&#x51FA;&#x5C5E;&#x6027;&#xFF0C;&#x8FD9;&#x662F;&#x56E0;&#x4E3A; Terraform &#x5FC5;&#x987B;&#x5728;&#x8BA1;&#x7B97;&#x8D44;&#x6E90;&#x95F4;&#x5173;&#x7CFB;&#x4E4B;&#x524D;&#x5C31;&#x80FD;&#x7406;&#x89E3;&#x5217;&#x8868;&#x4E2D;&#x7684;&#x503C;&#xFF0C;&#x4E3A;&#x4E86;&#x80FD;&#x591F;&#x5B89;&#x5168;&#x5730;&#x5B8C;&#x6210;&#x8868;&#x8FBE;&#x5F0F;&#x8BA1;&#x7B97;&#xFF0C;&#x6240;&#x4EE5;&#x9650;&#x5236;&#x53EA;&#x80FD;&#x4F7F;&#x7528;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#x7684;&#x540D;&#x79F0;&#x3002;</p>
<p><code>depends_on</code> &#x53EA;&#x80FD;&#x4F5C;&#x4E3A;&#x6700;&#x540E;&#x7684;&#x624B;&#x6BB5;&#x4F7F;&#x7528;&#xFF0C;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x4F7F;&#x7528; <code>depends_on</code>&#xFF0C;&#x6211;&#x4EEC;&#x5E94;&#x8BE5;&#x7528;&#x6CE8;&#x91CA;&#x8BB0;&#x5F55;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x5B83;&#x7684;&#x539F;&#x56E0;&#xFF0C;&#x4EE5;&#x4FBF;&#x4ECA;&#x540E;&#x4EE3;&#x7801;&#x7684;&#x7EF4;&#x62A4;&#x8005;&#x80FD;&#x591F;&#x7406;&#x89E3;&#x9690;&#x85CF;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x3002;</p>
<h3 id="count"><a name="count" class="anchor-navigation-ex-anchor" href="#count"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.6.2. count</h3>
<p>&#x4E00;&#x822C;&#x6765;&#x8BF4;&#xFF0C;&#x4E00;&#x4E2A; resource &#x5757;&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x4E2A;&#x5BF9;&#x5E94;&#x7684;&#x5B9E;&#x9645;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x3002;&#x4F46;&#x662F;&#x6709;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x5E0C;&#x671B;&#x521B;&#x5EFA;&#x591A;&#x4E2A;&#x76F8;&#x4F3C;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x6BD4;&#x5982;&#x521B;&#x5EFA;&#x4E00;&#x7EC4;&#x865A;&#x62DF;&#x673A;&#x3002;Terraform &#x63D0;&#x4F9B;&#x4E86;&#x4E24;&#x79CD;&#x65B9;&#x6CD5;&#x5B9E;&#x73B0;&#x8FD9;&#x4E2A;&#x76EE;&#x6807;&#xFF1A;<code>count</code> &#x4E0E; <code>for_each</code>&#x3002;</p>
<p><code>count</code> &#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x662F;&#x4EFB;&#x610F;&#x81EA;&#x7136;&#x6570;&#xFF0C;Terraform &#x4F1A;&#x521B;&#x5EFA; <code>count</code> &#x4E2A;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#xFF0C;&#x6BCF;&#x4E00;&#x4E2A;&#x5B9E;&#x4F8B;&#x90FD;&#x5BF9;&#x5E94;&#x4E86;&#x4E00;&#x4E2A;&#x72EC;&#x7ACB;&#x7684;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x4E14;&#x5728;&#x6267;&#x884C; Terraform &#x4EE3;&#x7801;&#x65F6;&#xFF0C;&#x8FD9;&#x4E9B;&#x5BF9;&#x8C61;&#x662F;&#x88AB;&#x5206;&#x522B;&#x521B;&#x5EFA;&#x3001;&#x66F4;&#x65B0;&#x6216;&#x8005;&#x9500;&#x6BC1;&#x7684;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;server&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">count</span> <span class="token punctuation">=</span> <span class="token number">4</span> <span class="token comment"># create four similar EC2 instances</span>

  <span class="token property">ami</span>           <span class="token punctuation">=</span> <span class="token string">&quot;ami-a1b2c3d4&quot;</span>
  <span class="token property">instance_type</span> <span class="token punctuation">=</span> <span class="token string">&quot;t2.micro&quot;</span>

  <span class="token property">tags</span> <span class="token punctuation">=</span> <span class="token punctuation">{</span>
    <span class="token property">Name</span> <span class="token punctuation">=</span> <span class="token string">&quot;Server <span class="token interpolation"><span class="token punctuation">$</span><span class="token punctuation">{</span><span class="token keyword">count</span><span class="token punctuation">.</span><span class="token type variable">index</span><span class="token punctuation">}</span></span>&quot;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5728; <code>resource</code> &#x5757;&#x4E2D;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x91CC;&#x4F7F;&#x7528; <code>count</code> &#x5BF9;&#x8C61;&#x6765;&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x7684; <code>count</code> &#x7D22;&#x5F15;&#x53F7;&#x3002;<code>count</code> &#x5BF9;&#x8C61;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#xFF1A;</p>
<ul>
<li><code>count.index</code>&#xFF1A;&#x4EE3;&#x8868;&#x5F53;&#x524D;&#x5BF9;&#x8C61;&#x5BF9;&#x5E94;&#x7684; <code>count</code> &#x4E0B;&#x6807;&#x7D22;&#x5F15;(&#x4ECE; <code>0</code> &#x5F00;&#x59CB;)</li>
</ul>
<p>&#x5982;&#x679C;&#x4E00;&#x4E2A; <code>resource</code> &#x5757;&#x5B9A;&#x4E49;&#x4E86; <code>count</code> &#x53C2;&#x6570;&#xFF0C;&#x90A3;&#x4E48; Terraform &#x4F1A;&#x628A;&#x8FD9;&#x79CD;&#x591A;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;&#x4E0E;&#x6CA1;&#x6709; <code>count</code> &#x53C2;&#x6570;&#x7684;&#x5355;&#x5B9E;&#x4F8B;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x533A;&#x522B;&#x5F00;&#xFF1A;</p>
<ul>
<li>&#x8BBF;&#x95EE;&#x5355;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;&#xFF1A;<code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>TYPE</span><span class="token punctuation">&gt;</span></span>.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>NAME</span><span class="token punctuation">&gt;</span></span></code>(&#x4F8B;&#x5982;&#xFF1A;<code>aws_instance.server</code>)</li>
<li>&#x8BBF;&#x95EE;&#x591A;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;&#xFF1A;<code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>TYPE</span><span class="token punctuation">&gt;</span></span>.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>NAME</span><span class="token punctuation">&gt;</span></span>[<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>INDEX</span><span class="token punctuation">&gt;</span></span>]</code> (&#x4F8B;&#x5982;&#xFF1A;<code>aws_instance.server[0]</code>&#xFF0C;<code>aws_instance.server[1]</code>)</li>
</ul>
<p>&#x58F0;&#x660E;&#x4E86; <code>count</code> &#x6216; <code>for_each</code> &#x7684;&#x8D44;&#x6E90;&#x5FC5;&#x987B;&#x4F7F;&#x7528;&#x4E0B;&#x6807;&#x7D22;&#x5F15;&#x6216;&#x8005;&#x952E;&#x6765;&#x8BBF;&#x95EE;&#x3002;</p>
<p><code>count</code> &#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x662F;&#x4EFB;&#x610F;&#x81EA;&#x7136;&#x6570;&#xFF0C;&#x7136;&#x800C;&#x4E0E; <code>resource</code> &#x7684;&#x5176;&#x4ED6;&#x53C2;&#x6570;&#x4E0D;&#x540C;&#xFF0C;<code>count</code> &#x7684;&#x503C;&#x5728; Terraform &#x8FDB;&#x884C;&#x4EFB;&#x4F55;&#x8FDC;&#x7A0B;&#x8D44;&#x6E90;&#x64CD;&#x4F5C;(&#x5B9E;&#x9645;&#x7684;&#x589E;&#x5220;&#x6539;&#x67E5;)&#x4E4B;&#x524D;&#x5FC5;&#x987B;&#x662F;&#x5DF2;&#x77E5;&#x7684;&#xFF0C;&#x8FD9;&#x4E5F;&#x5C31;&#x610F;&#x5473;&#x7740;&#x8D4B;&#x4E88; <code>count</code> &#x53C2;&#x6570;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x4E0D;&#x53EF;&#x4EE5;&#x5F15;&#x7528;&#x4EFB;&#x4F55;&#x5176;&#x4ED6;&#x8D44;&#x6E90;&#x7684;&#x8F93;&#x51FA;&#x5C5E;&#x6027;(&#x4F8B;&#x5982;&#x7531;&#x5176;&#x4ED6;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x521B;&#x5EFA;&#x65F6;&#x8FD4;&#x56DE;&#x7684;&#x4E00;&#x4E2A;&#x552F;&#x4E00;&#x7684; ID)&#x3002;</p>
<h3 id="foreach"><a name="foreach" class="anchor-navigation-ex-anchor" href="#foreach"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.6.3. for_each</h3>
<p><code>for_each</code> &#x662F; Terraform 0.12.6 &#x5F00;&#x59CB;&#x5F15;&#x5165;&#x7684;&#x65B0;&#x7279;&#x6027;&#x3002;&#x4E00;&#x4E2A; <code>resource</code> &#x5757;&#x4E0D;&#x5141;&#x8BB8;&#x540C;&#x65F6;&#x58F0;&#x660E; <code>count</code> &#x4E0E; <code>for_each</code>&#x3002;<code>for_each</code> &#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x662F;&#x4E00;&#x4E2A; <code>map</code> &#x6216;&#x662F;&#x4E00;&#x4E2A; <code>set(string)</code>&#xFF0C;Terraform &#x4F1A;&#x4E3A;&#x96C6;&#x5408;&#x4E2D;&#x6BCF;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x90FD;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x72EC;&#x7ACB;&#x7684;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#xFF0C;&#x548C; <code>count</code> &#x4E00;&#x6837;&#xFF0C;&#x6BCF;&#x4E00;&#x4E2A;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x5728;&#x6267;&#x884C; Terraform &#x4EE3;&#x7801;&#x65F6;&#x90FD;&#x662F;&#x72EC;&#x7ACB;&#x521B;&#x5EFA;&#x3001;&#x4FEE;&#x6539;&#x3001;&#x9500;&#x6BC1;&#x7684;&#x3002;</p>
<p>&#x4F7F;&#x7528; <code>map</code> &#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;azurerm_resource_group&quot;</span></span> <span class="token string">&quot;rg&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">for_each</span> <span class="token punctuation">=</span> <span class="token punctuation">{</span>
    <span class="token property">a_group</span> <span class="token punctuation">=</span> <span class="token string">&quot;eastus&quot;</span>
    <span class="token property">another_group</span> <span class="token punctuation">=</span> <span class="token string">&quot;westus2&quot;</span>
  <span class="token punctuation">}</span>
  <span class="token property">name</span>     <span class="token punctuation">=</span> each.key
  <span class="token property">location</span> <span class="token punctuation">=</span> each.value
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4F7F;&#x7528; <code>set(string)</code> &#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_iam_user&quot;</span></span> <span class="token string">&quot;the-accounts&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">for_each</span> <span class="token punctuation">=</span> toset( <span class="token punctuation">[</span><span class="token string">&quot;Todd&quot;</span>, <span class="token string">&quot;James&quot;</span>, <span class="token string">&quot;Alice&quot;</span>, <span class="token string">&quot;Dottie&quot;</span><span class="token punctuation">]</span> )
  <span class="token property">name</span>     <span class="token punctuation">=</span> each.key
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5728;&#x58F0;&#x660E;&#x4E86; <code>for_each</code> &#x53C2;&#x6570;&#x7684; <code>resource</code> &#x5757;&#x5185;&#x4F7F;&#x7528; <code>each</code> &#x5BF9;&#x8C61;&#x6765;&#x8BBF;&#x95EE;&#x5F53;&#x524D;&#x7684;&#x8FED;&#x4EE3;&#x5668;&#x5BF9;&#x8C61;&#xFF1A;</p>
<ul>
<li><code>each.key</code>&#xFF1A;<code>map</code> &#x7684;&#x952E;&#xFF0C;&#x6216;&#x662F; <code>set</code> &#x4E2D;&#x7684;&#x503C;</li>
<li><code>each.value</code>&#xFF1A;<code>map</code> &#x7684;&#x503C;&#xFF0C;&#x6216;&#x662F; <code>set</code> &#x4E2D;&#x7684;&#x503C;</li>
</ul>
<p>&#x5982;&#x679C; <code>for_each</code> &#x7684;&#x503C;&#x662F;&#x4E00;&#x4E2A; <code>set</code>&#xFF0C;&#x90A3;&#x4E48; <code>each.key</code> &#x548C; <code>each.value</code> &#x662F;&#x76F8;&#x7B49;&#x7684;&#x3002;</p>
<p>&#x4F7F;&#x7528; <code>for_each</code> &#x65F6;&#xFF0C;<code>map</code> &#x7684;&#x6240;&#x6709;&#x952E;&#x3001;<code>set</code> &#x7684;&#x6240;&#x6709; <code>string</code> &#x503C;&#x90FD;&#x5FC5;&#x987B;&#x662F;&#x5DF2;&#x77E5;&#x7684;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x72B6;&#x6001;&#x6587;&#x4EF6;&#x4E2D;&#x5DF2;&#x6709;&#x8BB0;&#x5F55;&#x7684;&#x503C;&#x3002;&#x6240;&#x4EE5;&#x6709;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x5728;&#x6267;&#x884C; <code>terraform apply</code> &#x65F6;&#x6DFB;&#x52A0; <code>-target</code> &#x53C2;&#x6570;&#xFF0C;&#x5B9E;&#x73B0;&#x5206;&#x6B65;&#x521B;&#x5EFA;&#x3002;&#x53E6;&#x5916;&#xFF0C;<code>for_each</code> &#x6240;&#x4F7F;&#x7528;&#x7684;&#x952E;&#x96C6;&#x5408;&#x4E0D;&#x80FD;&#x591F;&#x5305;&#x542B;&#x6216;&#x4F9D;&#x8D56;&#x975E;&#x7EAF;&#x51FD;&#x6570;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x53CD;&#x590D;&#x6267;&#x884C;&#x4F1A;&#x8FD4;&#x56DE;&#x4E0D;&#x540C;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x4F8B;&#x5982; <code>uuid</code>&#x3001;<code>bcrypt</code>&#x3001;<code>timestamp</code> &#x7B49;&#x3002;</p>
<p>&#x5F53;&#x4E00;&#x4E2A; <code>resource</code> &#x58F0;&#x660E;&#x4E86; <code>for_each</code> &#x65F6;&#xFF0C;Terraform &#x4F1A;&#x628A;&#x8FD9;&#x79CD;&#x591A;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;&#x4E0E;&#x6CA1;&#x6709; <code>count</code> &#x53C2;&#x6570;&#x7684;&#x5355;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;&#x533A;&#x522B;&#x5F00;&#xFF1A;</p>
<ul>
<li>&#x8BBF;&#x95EE;&#x5355;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;&#xFF1A;<code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>TYPE</span><span class="token punctuation">&gt;</span></span>.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>NAME</span><span class="token punctuation">&gt;</span></span></code>(&#x4F8B;&#x5982;&#xFF1A;<code>aws_instance.server</code>)</li>
<li>&#x8BBF;&#x95EE;&#x591A;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;&#xFF1A;<code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>TYPE</span><span class="token punctuation">&gt;</span></span>.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>NAME</span><span class="token punctuation">&gt;</span></span>[<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>KE</span><span class="token punctuation">&gt;</span></span>]</code> (&#x4F8B;&#x5982;&#xFF1A;<code>aws_instance.server[&quot;ap-northeast-1&quot;]</code>&#xFF0C;<code>aws_instance.server[&quot;ap-northeast-2&quot;]</code>)</li>
</ul>
<p>&#x58F0;&#x660E;&#x4E86;<code>count</code>&#x6216; <code>for_each</code> &#x7684;&#x8D44;&#x6E90;&#x5FC5;&#x987B;&#x4F7F;&#x7528;&#x4E0B;&#x6807;&#x7D22;&#x5F15;&#x6216;&#x8005;&#x952E;&#x6765;&#x8BBF;&#x95EE;&#x3002;</p>
<p>&#x7531;&#x4E8E; Terraform &#x6CA1;&#x6709;&#x7528;&#x4EE5;&#x58F0;&#x660E; <code>set</code> &#x7684;&#x5B57;&#x9762;&#x91CF;&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x6709;&#x65F6;&#x9700;&#x8981;&#x4F7F;&#x7528; <code>toset</code> &#x51FD;&#x6570;&#x628A; <code>list(string)</code> &#x8F6C;&#x6362;&#x4E3A; <code>set(string)</code>&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">locals</span> <span class="token punctuation">{</span>
  <span class="token property">subnet_ids</span> <span class="token punctuation">=</span> toset(<span class="token punctuation">[</span>
    <span class="token string">&quot;subnet-abcdef&quot;</span>,
    <span class="token string">&quot;subnet-012345&quot;</span>,
  <span class="token punctuation">]</span>)
<span class="token punctuation">}</span>

<span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;server&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">for_each</span> <span class="token punctuation">=</span> local.subnet_ids

  <span class="token property">ami</span>           <span class="token punctuation">=</span> <span class="token string">&quot;ami-a1b2c3d4&quot;</span>
  <span class="token property">instance_type</span> <span class="token punctuation">=</span> <span class="token string">&quot;t2.micro&quot;</span>
  <span class="token property">subnet_id</span>     <span class="token punctuation">=</span> each.key <span class="token comment"># note: each.key and each.value are the same for a set</span>

  <span class="token property">tags</span> <span class="token punctuation">=</span> <span class="token punctuation">{</span>
    <span class="token property">Name</span> <span class="token punctuation">=</span> <span class="token string">&quot;Server <span class="token interpolation"><span class="token punctuation">$</span><span class="token punctuation">{</span>each<span class="token punctuation">.</span>key<span class="token punctuation">}</span></span>&quot;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5728;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x7528; <code>toset</code> &#x628A;&#x4E00;&#x4E2A; <code>list(string)</code> &#x8F6C;&#x6362;&#x6210;&#x4E86; <code>set(string)</code>&#xFF0C;&#x7136;&#x540E;&#x8D4B;&#x4E88; <code>for_each</code>&#x3002;&#x5728;&#x8F6C;&#x6362;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;<code>list</code> &#x4E2D;&#x6240;&#x6709;&#x91CD;&#x590D;&#x7684;&#x5143;&#x7D20;&#x4F1A;&#x88AB;&#x629B;&#x5F03;&#xFF0C;&#x53EA;&#x5269;&#x4E0B;&#x4E0D;&#x91CD;&#x590D;&#x7684;&#x5143;&#x7D20;&#xFF0C;&#x4F8B;&#x5982; <code>toset([&quot;b&quot;, &quot;a&quot;, &quot;b&quot;])</code> &#x7684;&#x7ED3;&#x679C;&#x53EA;&#x6709;<code>&quot;a&quot;</code>&#x548C;<code>&quot;b&quot;</code>&#xFF0C;&#x5E76;&#x4E14; <code>set</code> &#x7684;&#x5143;&#x7D20;&#x6CA1;&#x6709;&#x7279;&#x5B9A;&#x987A;&#x5E8F;&#x3002;</p>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x8981;&#x628A;&#x4E00;&#x4E2A;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x4E88; <code>for_each</code>&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5B9A;&#x4E49;&#x53D8;&#x91CF;&#x7684;&#x7C7B;&#x578B;&#x7EA6;&#x675F;&#x6765;&#x907F;&#x514D;&#x663E;&#x5F0F;&#x8C03;&#x7528; <code>toset</code> &#x8F6C;&#x6362;&#x7C7B;&#x578B;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">variable<span class="token type variable"> &quot;subnet_ids&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">type</span> <span class="token punctuation">=</span> set(string)
<span class="token punctuation">}</span>

<span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;server&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">for_each</span> <span class="token punctuation">=</span> var.subnet_ids

  <span class="token comment"># (and the other arguments as above)</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x5728;-foreach-&#x548C;-count-&#x4E4B;&#x95F4;&#x9009;&#x62E9;"><a name="&#x5728;-foreach-&#x548C;-count-&#x4E4B;&#x95F4;&#x9009;&#x62E9;" class="anchor-navigation-ex-anchor" href="#&#x5728;-foreach-&#x548C;-count-&#x4E4B;&#x95F4;&#x9009;&#x62E9;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.6.4. &#x5728; for_each &#x548C; count &#x4E4B;&#x95F4;&#x9009;&#x62E9;</h3>
<p>&#x5982;&#x679C;&#x521B;&#x5EFA;&#x7684;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#x5F7C;&#x6B64;&#x4E4B;&#x95F4;&#x51E0;&#x4E4E;&#x5B8C;&#x5168;&#x4E00;&#x81F4;&#xFF0C;&#x90A3;&#x4E48; <code>count</code> &#x6BD4;&#x8F83;&#x5408;&#x9002;&#x3002;&#x5982;&#x679C;&#x5F7C;&#x6B64;&#x4E4B;&#x95F4;&#x7684;&#x53C2;&#x6570;&#x5DEE;&#x5F02;&#x65E0;&#x6CD5;&#x76F4;&#x63A5;&#x4ECE; <code>count</code> &#x7684;&#x4E0B;&#x6807;&#x6D3E;&#x751F;&#xFF0C;&#x90A3;&#x4E48;&#x4F7F;&#x7528; <code>for_each</code> &#x4F1A;&#x66F4;&#x52A0;&#x5B89;&#x5168;&#x3002;</p>
<p>&#x5728; Terraform &#x5F15;&#x5165; <code>for_each</code> &#x4E4B;&#x524D;&#xFF0C;&#x6211;&#x4EEC;&#x7ECF;&#x5E38;&#x4F7F;&#x7528; <code>count.index</code> &#x642D;&#x914D; <code>length</code> &#x51FD;&#x6570;&#x548C; <code>list</code> &#x6765;&#x521B;&#x5EFA;&#x591A;&#x4E2A;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">variable<span class="token type variable"> &quot;subnet_ids&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">type</span> <span class="token punctuation">=</span> list(string)
<span class="token punctuation">}</span>

<span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;server&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># Create one instance for each subnet</span>
  <span class="token property">count</span> <span class="token punctuation">=</span> length(var.subnet_ids)

  <span class="token property">ami</span>           <span class="token punctuation">=</span> <span class="token string">&quot;ami-a1b2c3d4&quot;</span>
  <span class="token property">instance_type</span> <span class="token punctuation">=</span> <span class="token string">&quot;t2.micro&quot;</span>
  <span class="token property">subnet_id</span>     <span class="token punctuation">=</span> var.subnet_ids<span class="token punctuation">[</span>count.index<span class="token punctuation">]</span>

  <span class="token property">tags</span> <span class="token punctuation">=</span> <span class="token punctuation">{</span>
    <span class="token property">Name</span> <span class="token punctuation">=</span> <span class="token string">&quot;Server <span class="token interpolation"><span class="token punctuation">$</span><span class="token punctuation">{</span><span class="token keyword">count</span><span class="token punctuation">.</span><span class="token type variable">index</span><span class="token punctuation">}</span></span>&quot;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8FD9;&#x79CD;&#x5B9E;&#x73B0;&#x65B9;&#x6CD5;&#x662F;&#x8106;&#x5F31;&#x7684;&#xFF0C;&#x56E0;&#x4E3A;&#x8D44;&#x6E90;&#x4ECD;&#x7136;&#x662F;&#x4EE5;&#x4ED6;&#x4EEC;&#x7684;&#x4E0B;&#x6807;&#x800C;&#x4E0D;&#x662F;&#x5B9E;&#x9645;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x503C;&#x6765;&#x533A;&#x5206;&#x7684;&#x3002;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x4ECE; <code>subnet_ids</code> &#x5217;&#x8868;&#x7684;&#x4E2D;&#x95F4;&#x79FB;&#x9664;&#x4E86;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#xFF0C;&#x90A3;&#x4E48;&#x4ECE;&#x8BE5;&#x4F4D;&#x7F6E;&#x8D77;&#x540E;&#x7EED;&#x6240;&#x6709;&#x7684; <code>aws_instance</code> &#x90FD;&#x4F1A;&#x53D1;&#x73B0;&#x5B83;&#x4EEC;&#x7684; <code>subnet_id</code> &#x53D1;&#x751F;&#x4E86;&#x53D8;&#x5316;&#xFF0C;&#x7ED3;&#x679C;&#x5C31;&#x662F;&#x6240;&#x6709;&#x540E;&#x7EED;&#x7684; <code>aws_instance</code> &#x90FD;&#x9700;&#x8981;&#x66F4;&#x65B0;&#x3002;&#x8FD9;&#x79CD;&#x573A;&#x666F;&#x4E0B;&#x5982;&#x679C;&#x4F7F;&#x7528; <code>for_each</code> &#x5C31;&#x66F4;&#x4E3A;&#x59A5;&#x5F53;&#xFF0C;&#x5982;&#x679C;&#x4F7F;&#x7528; <code>for_each</code>&#xFF0C;&#x90A3;&#x4E48;&#x53EA;&#x6709;&#x88AB;&#x79FB;&#x9664;&#x7684; <code>subnet_id</code> &#x5BF9;&#x5E94;&#x7684; <code>aws_instance</code> &#x4F1A;&#x88AB;&#x9500;&#x6BC1;&#x3002;</p>
<h3 id="provider"><a name="provider" class="anchor-navigation-ex-anchor" href="#provider"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.6.5. provider</h3>
<p>&#x5173;&#x4E8E; <code>provider</code> &#x7684;&#x5B9A;&#x4E49;&#x6211;&#x4EEC;&#x5728;&#x524D;&#x9762;&#x4ECB;&#x7ECD; Provider &#x7684;&#x7AE0;&#x8282;&#x5DF2;&#x7ECF;&#x63D0;&#x5230;&#x8FC7;&#x4E86;&#xFF0C;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x58F0;&#x660E;&#x4E86;&#x540C;&#x4E00;&#x7C7B;&#x578B; Provider &#x7684;&#x591A;&#x4E2A;&#x5B9E;&#x4F8B;&#xFF0C;&#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x5728;&#x521B;&#x5EFA;&#x8D44;&#x6E90;&#x65F6;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x6307;&#x5B9A; <code>provider</code> &#x53C2;&#x6570;&#x9009;&#x62E9;&#x8981;&#x4F7F;&#x7528;&#x7684; Provider &#x5B9E;&#x4F8B;&#x3002;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x6307;&#x5B9A; <code>provider</code> &#x53C2;&#x6570;&#xFF0C;&#x90A3;&#x4E48; Terraform &#x9ED8;&#x8BA4;&#x4F7F;&#x7528;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x540D;&#x4E2D;&#x7B2C;&#x4E00;&#x4E2A;&#x5355;&#x8BCD;&#x6240;&#x5BF9;&#x5E94;&#x7684; Provider &#x5B9E;&#x4F8B;&#xFF0C;&#x4F8B;&#x5982; <code>google_compute_instance</code> &#x7684;&#x9ED8;&#x8BA4; Provider &#x5B9E;&#x4F8B;&#x5C31;&#x662F; <code>google</code>&#xFF0C;<code>aws_instance</code> &#x7684;&#x9ED8;&#x8BA4; Provider &#x5C31;&#x662F; <code>aws</code>&#x3002;</p>
<p>&#x6307;&#x5B9A; <code>provider</code> &#x53C2;&#x6570;&#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token comment"># default configuration</span>
<span class="token keyword">provider<span class="token type variable"> &quot;google&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">region</span> <span class="token punctuation">=</span> <span class="token string">&quot;us-central1&quot;</span>
<span class="token punctuation">}</span>

<span class="token comment"># alternate configuration, whose alias is &quot;europe&quot;</span>
<span class="token keyword">provider<span class="token type variable"> &quot;google&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">alias</span>  <span class="token punctuation">=</span> <span class="token string">&quot;europe&quot;</span>
  <span class="token property">region</span> <span class="token punctuation">=</span> <span class="token string">&quot;europe-west1&quot;</span>
<span class="token punctuation">}</span>

<span class="token keyword">resource <span class="token type variable">&quot;google_compute_instance&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># This &quot;provider&quot; meta-argument selects the google provider</span>
  <span class="token comment"># configuration whose alias is &quot;europe&quot;, rather than the</span>
  <span class="token comment"># default configuration.</span>
  <span class="token property">provider</span> <span class="token punctuation">=</span> google.europe

  <span class="token comment"># ...</span>
<span class="token punctuation">}</span>
</code></pre>
<p><code>provider</code>&#x53C2;&#x6570;&#x671F;&#x5F85;&#x7684;&#x8D4B;&#x503C;&#x662F;<code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>PROVIDER</span><span class="token punctuation">&gt;</span></span></code>&#x6216;&#x662F;<code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>PROVIDER</span><span class="token punctuation">&gt;</span></span>.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>ALIAS</span><span class="token punctuation">&gt;</span></span></code>&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x53CC;&#x5F15;&#x53F7;&#x3002;&#x56E0;&#x4E3A;&#x5728;Terraform&#x5F00;&#x59CB;&#x8BA1;&#x7B97;&#x4F9D;&#x8D56;&#x8DEF;&#x5F84;&#x56FE;&#x65F6;&#xFF0C;provider&#x5173;&#x7CFB;&#x5FC5;&#x987B;&#x662F;&#x5DF2;&#x77E5;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x9664;&#x4E86;&#x8FD9;&#x4E24;&#x79CD;&#x4EE5;&#x5916;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x662F;&#x4E0D;&#x88AB;&#x63A5;&#x53D7;&#x7684;&#x3002;</p>
<h3 id="lifecycle"><a name="lifecycle" class="anchor-navigation-ex-anchor" href="#lifecycle"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.6.6. lifecycle</h3>
<p>&#x901A;&#x5E38;&#x4E00;&#x4E2A;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x5728;&#x524D;&#x9762;<a href="#&#x8D44;&#x6E90;&#x7684;&#x884C;&#x4E3A;">&#x201C;&#x8D44;&#x6E90;&#x7684;&#x884C;&#x4E3A;&#x201D;</a>&#x4E00;&#x8282;&#x4E2D;&#x5DF2;&#x7ECF;&#x63CF;&#x8FF0;&#x4E86;&#xFF0C;&#x4F46;&#x662F;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x7528; <code>lifecycle</code> &#x5757;&#x6765;&#x5B9A;&#x4E00;&#x4E2A;&#x4E0D;&#x4E00;&#x6837;&#x7684;&#x884C;&#x4E3A;&#x65B9;&#x5F0F;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;azurerm_resource_group&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># ...</span>

  <span class="token keyword">lifecycle</span> <span class="token punctuation">{</span>
    <span class="token property">create_before_destroy</span> <span class="token punctuation">=</span> <span class="token boolean">true</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p><code>lifecycle</code> &#x5757;&#x548C;&#x5B83;&#x7684;&#x5185;&#x5BB9;&#x90FD;&#x5C5E;&#x4E8E;&#x5143;&#x53C2;&#x6570;&#xFF0C;&#x53EF;&#x4EE5;&#x88AB;&#x58F0;&#x660E;&#x4E8E;&#x4EFB;&#x610F;&#x7C7B;&#x578B;&#x7684;&#x8D44;&#x6E90;&#x5757;&#x5185;&#x90E8;&#x3002;Terraform &#x652F;&#x6301;&#x5982;&#x4E0B;&#x51E0;&#x79CD; <code>lifecycle</code>&#xFF1A;</p>
<ul>
<li><code>create_before_destroy</code> (<code>bool</code>)&#xFF1A;&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5F53; Terraform &#x9700;&#x8981;&#x4FEE;&#x6539;&#x4E00;&#x4E2A;&#x7531;&#x4E8E;&#x670D;&#x52A1;&#x7AEF; API &#x9650;&#x5236;&#x5BFC;&#x81F4;&#x65E0;&#x6CD5;&#x76F4;&#x63A5;&#x5347;&#x7EA7;&#x7684;&#x8D44;&#x6E90;&#x65F6;&#xFF0C;Terraform &#x4F1A;&#x5220;&#x9664;&#x73B0;&#x6709;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#xFF0C;&#x7136;&#x540E;&#x7528;&#x65B0;&#x7684;&#x914D;&#x7F6E;&#x53C2;&#x6570;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x53D6;&#x4EE3;&#x4E4B;&#x3002;<code>create_before_destroy</code> &#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x4FEE;&#x6539;&#x8FD9;&#x4E2A;&#x884C;&#x4E3A;&#xFF0C;&#x4F7F;&#x5F97; Terraform &#x9996;&#x5148;&#x521B;&#x5EFA;&#x65B0;&#x5BF9;&#x8C61;&#xFF0C;&#x53EA;&#x6709;&#x5728;&#x65B0;&#x5BF9;&#x8C61;&#x6210;&#x529F;&#x521B;&#x5EFA;&#x5E76;&#x53D6;&#x4EE3;&#x8001;&#x5BF9;&#x8C61;&#x540E;&#x518D;&#x9500;&#x6BC1;&#x8001;&#x5BF9;&#x8C61;&#x3002;&#x8FD9;&#x5E76;&#x4E0D;&#x662F;&#x9ED8;&#x8BA4;&#x7684;&#x884C;&#x4E3A;&#xFF0C;&#x56E0;&#x4E3A;&#x8BB8;&#x591A;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x8D44;&#x6E90;&#x9700;&#x8981;&#x6709;&#x4E00;&#x4E2A;&#x552F;&#x4E00;&#x7684;&#x540D;&#x5B57;&#x6216;&#x662F;&#x522B;&#x7684;&#x4EC0;&#x4E48;&#x6807;&#x8BC6;&#x5C5E;&#x6027;&#xFF0C;&#x5728;&#x65B0;&#x8001;&#x5BF9;&#x8C61;&#x5E76;&#x5B58;&#x65F6;&#x4E5F;&#x8981;&#x7B26;&#x5408;&#x8FD9;&#x79CD;&#x7EA6;&#x675F;&#x3002;&#x6709;&#x4E9B;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x6709;&#x7279;&#x522B;&#x7684;&#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x4E3A;&#x6BCF;&#x4E2A;&#x5BF9;&#x8C61;&#x540D;&#x79F0;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x968F;&#x673A;&#x7684;&#x524D;&#x7F00;&#x4EE5;&#x9632;&#x6B62;&#x51B2;&#x7A81;&#x3002;Terraform &#x4E0D;&#x80FD;&#x9ED8;&#x8BA4;&#x91C7;&#x7528;&#x8FD9;&#x79CD;&#x884C;&#x4E3A;&#xFF0C;&#x6240;&#x4EE5;&#x5728;&#x4F7F;&#x7528; <code>create_before_destroy</code> &#x524D;&#x4F60;&#x5FC5;&#x987B;&#x4E86;&#x89E3;&#x6BCF;&#x4E00;&#x79CD;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x5728;&#x8FD9;&#x65B9;&#x9762;&#x7684;&#x7EA6;&#x675F;&#x3002;</li>
<li><code>prevent_destroy</code> (<code>bool</code>)&#xFF1A;&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x4E00;&#x4E2A;&#x4FDD;&#x9669;&#x63AA;&#x65BD;&#xFF0C;&#x53EA;&#x8981;&#x5B83;&#x88AB;&#x8BBE;&#x7F6E;&#x4E3A; <code>true</code> &#x65F6;&#xFF0C;Terraform &#x4F1A;&#x62D2;&#x7EDD;&#x6267;&#x884C;&#x4EFB;&#x4F55;&#x53EF;&#x80FD;&#x4F1A;&#x9500;&#x6BC1;&#x8BE5;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x8D44;&#x6E90;&#x7684;&#x53D8;&#x66F4;&#x8BA1;&#x5212;&#x3002;&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x9884;&#x9632;&#x610F;&#x5916;&#x5220;&#x9664;&#x5173;&#x952E;&#x8D44;&#x6E90;&#xFF0C;&#x4F8B;&#x5982;&#x9519;&#x8BEF;&#x5730;&#x6267;&#x884C;&#x4E86; <code>terraform destroy</code>&#xFF0C;&#x6216;&#x8005;&#x662F;&#x610F;&#x5916;&#x4FEE;&#x6539;&#x4E86;&#x8D44;&#x6E90;&#x7684;&#x67D0;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x5BFC;&#x81F4; Terraform &#x51B3;&#x5B9A;&#x5220;&#x9664;&#x5E76;&#x91CD;&#x5EFA;&#x65B0;&#x7684;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#x3002;&#x5728; <code>resource</code> &#x5757;&#x5185;&#x58F0;&#x660E;&#x4E86; <code>prevent_destroy = true</code> &#x4F1A;&#x5BFC;&#x81F4;&#x65E0;&#x6CD5;&#x6267;&#x884C; <code>terraform destroy</code>&#xFF0C;&#x6240;&#x4EE5;&#x5BF9;&#x5B83;&#x7684;&#x4F7F;&#x7528;&#x8981;&#x8282;&#x5236;&#x3002;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;&#x8BE5;&#x63AA;&#x65BD;&#x65E0;&#x6CD5;&#x9632;&#x6B62;&#x6211;&#x4EEC;&#x5220;&#x9664; <code>resource</code> &#x5757;&#x540E; Terraform &#x5220;&#x9664;&#x76F8;&#x5173;&#x8D44;&#x6E90;&#xFF0C;&#x56E0;&#x4E3A;&#x5BF9;&#x5E94;&#x7684; <code>prevent_destroy = true</code> &#x58F0;&#x660E;&#x4E5F;&#x88AB;&#x4E00;&#x5E76;&#x5220;&#x9664;&#x4E86;&#x3002;</li>
<li><code>ignore_changes</code> (<code>list(string)</code>)&#xFF1A;&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;Terraform &#x68C0;&#x6D4B;&#x5230;&#x4EE3;&#x7801;&#x63CF;&#x8FF0;&#x7684;&#x914D;&#x7F6E;&#x4E0E;&#x771F;&#x5B9E;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x5BF9;&#x8C61;&#x4E4B;&#x95F4;&#x6709;&#x4EFB;&#x4F55;&#x5DEE;&#x5F02;&#x65F6;&#x90FD;&#x4F1A;&#x8BA1;&#x7B97;&#x4E00;&#x4E2A;&#x53D8;&#x66F4;&#x8BA1;&#x5212;&#x6765;&#x66F4;&#x65B0;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x5BF9;&#x8C61;&#xFF0C;&#x4F7F;&#x4E4B;&#x7B26;&#x5408;&#x4EE3;&#x7801;&#x63CF;&#x8FF0;&#x7684;&#x72B6;&#x6001;&#x3002;&#x5728;&#x4E00;&#x4E9B;&#x975E;&#x5E38;&#x7F55;&#x89C1;&#x7684;&#x573A;&#x666F;&#x4E0B;&#xFF0C;&#x5B9E;&#x9645;&#x7684;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x5BF9;&#x8C61;&#x4F1A;&#x88AB; Terraform &#x4E4B;&#x5916;&#x7684;&#x6D41;&#x7A0B;&#x6240;&#x4FEE;&#x6539;&#xFF0C;&#x8FD9;&#x5C31;&#x4F1A;&#x4F7F;&#x5F97; Terraform &#x4E0D;&#x505C;&#x5730;&#x5C1D;&#x8BD5;&#x4FEE;&#x6539;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x5BF9;&#x8C61;&#x4EE5;&#x5F25;&#x5408;&#x548C;&#x4EE3;&#x7801;&#x4E4B;&#x95F4;&#x7684;&#x5DEE;&#x5F02;&#x3002;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8BBE;&#x5B9A; <code>ignore_changes</code> &#x6765;&#x6307;&#x793A; Terraform &#x5FFD;&#x7565;&#x67D0;&#x4E9B;&#x5C5E;&#x6027;&#x7684;&#x53D8;&#x66F4;&#x3002;<code>ignore_changes</code> &#x7684;&#x503C;&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x7EC4;&#x5728;&#x521B;&#x5EFA;&#x65F6;&#x9700;&#x8981;&#x6309;&#x7167;&#x4EE3;&#x7801;&#x5B9A;&#x4E49;&#x7684;&#x503C;&#x6765;&#x521B;&#x5EFA;&#xFF0C;&#x4F46;&#x5728;&#x66F4;&#x65B0;&#x65F6;&#x4E0D;&#x9700;&#x8981;&#x8003;&#x8651;&#x503C;&#x7684;&#x53D8;&#x5316;&#x7684;&#x5C5E;&#x6027;&#x540D;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</li>
</ul>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># ...</span>

  <span class="token keyword">lifecycle</span> <span class="token punctuation">{</span>
    <span class="token property">ignore_changes</span> <span class="token punctuation">=</span> <span class="token punctuation">[</span>
      <span class="token comment"># Ignore changes to tags, e.g. because a management agent</span>
      <span class="token comment"># updates these based on some ruleset managed elsewhere.</span>
      tags,
    <span class="token punctuation">]</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x5FFD;&#x7565; <code>map</code> &#x4E2D;&#x7279;&#x5B9A;&#x7684;&#x5143;&#x7D20;&#xFF0C;&#x4F8B;&#x5982; <code>tags[&quot;Name&quot;]</code>&#xFF0C;&#x4F46;&#x662F;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;&#x5982;&#x679C;&#x4F60;&#x662F;&#x60F3;&#x5FFD;&#x7565; <code>map</code> &#x4E2D;&#x7279;&#x5B9A;&#x5143;&#x7D20;&#x7684;&#x53D8;&#x66F4;&#xFF0C;&#x90A3;&#x4E48;&#x4F60;&#x5FC5;&#x987B;&#x9996;&#x5148;&#x786E;&#x4FDD; <code>map</code> &#x4E2D;&#x542B;&#x6709;&#x8FD9;&#x4E2A;&#x5143;&#x7D20;&#x3002;&#x5982;&#x679C;&#x4E00;&#x5F00;&#x59CB; <code>map</code> &#x4E2D;&#x5E76;&#x6CA1;&#x6709;&#x8FD9;&#x4E2A;&#x952E;&#xFF0C;&#x800C;&#x540E;&#x5916;&#x90E8;&#x7CFB;&#x7EDF;&#x6DFB;&#x52A0;&#x4E86;&#x8FD9;&#x4E2A;&#x952E;&#xFF0C;&#x90A3;&#x4E48; Terraform &#x8FD8;&#x662F;&#x4F1A;&#x628A;&#x5B83;&#x5F53;&#x6210;&#x4E00;&#x6B21;&#x53D8;&#x66F4;&#x6765;&#x5904;&#x7406;&#x3002;&#x6BD4;&#x8F83;&#x597D;&#x7684;&#x65B9;&#x6CD5;&#x662F;&#x4F60;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x5148;&#x4E3A;&#x8FD9;&#x4E2A;&#x952E;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5360;&#x4F4D;&#x5143;&#x7D20;&#x6765;&#x786E;&#x4FDD;&#x8FD9;&#x4E2A;&#x952E;&#x5DF2;&#x7ECF;&#x5B58;&#x5728;&#xFF0C;&#x8FD9;&#x6837;&#x5728;&#x5916;&#x90E8;&#x7CFB;&#x7EDF;&#x4FEE;&#x6539;&#x4E86;&#x952E;&#x5BF9;&#x5E94;&#x7684;&#x503C;&#x4EE5;&#x540E; Terraform &#x4F1A;&#x5FFD;&#x7565;&#x8FD9;&#x4E2A;&#x53D8;&#x66F4;&#x3002;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># ...</span>

  <span class="token property">tags</span> <span class="token punctuation">=</span> <span class="token punctuation">{</span>
    <span class="token comment"># Initial value for Name is overridden by our automatic scheduled</span>
    <span class="token comment"># re-tagging process; changes to this are ignored by ignore_changes</span>
    <span class="token comment"># below.</span>
    <span class="token property">Name</span> <span class="token punctuation">=</span> <span class="token string">&quot;placeholder&quot;</span>
  <span class="token punctuation">}</span>

  <span class="token keyword">lifecycle</span> <span class="token punctuation">{</span>
    <span class="token property">ignore_changes</span> <span class="token punctuation">=</span> <span class="token punctuation">[</span>
      tags<span class="token punctuation">[</span><span class="token string">&quot;Name&quot;</span><span class="token punctuation">]</span>,
    <span class="token punctuation">]</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x9664;&#x4E86;&#x4F7F;&#x7528;&#x4E00;&#x4E2A; <code>list(string)</code>&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5173;&#x952E;&#x5B57; <code>all</code> &#xFF0C;&#x8FD9;&#x65F6; Terraform &#x4F1A;&#x5FFD;&#x7565;&#x8D44;&#x6E90;&#x4E00;&#x5207;&#x5C5E;&#x6027;&#x7684;&#x53D8;&#x66F4;&#xFF0C;&#x8FD9;&#x6837; Terraform &#x53EA;&#x4F1A;&#x521B;&#x5EFA;&#x6216;&#x9500;&#x6BC1;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x4F46;&#x7EDD;&#x4E0D;&#x4F1A;&#x5C1D;&#x8BD5;&#x66F4;&#x65B0;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x3002;&#x4F60;&#x53EA;&#x80FD;&#x5728; <code>ignore_changes</code> &#x91CC;&#x5FFD;&#x7565;&#x6240;&#x5C5E;&#x7684; <code>resource</code> &#x7684;&#x5C5E;&#x6027;&#xFF0C;<code>ignore_changes</code> &#x4E0D;&#x53EF;&#x4EE5;&#x8D4B;&#x4E88;&#x5B83;&#x81EA;&#x8EAB;&#x6216;&#x662F;&#x5176;&#x4ED6;&#x4EFB;&#x4F55;&#x5143;&#x53C2;&#x6570;&#x3002;</p>
<ul>
<li><code>replace_triggered_by</code> (&#x5305;&#x542B;&#x8D44;&#x6E90;&#x5F15;&#x7528;&#x7684;&#x5217;&#x8868;)&#xFF1A;&#x5F3A;&#x5236; Terraform &#x5728;&#x5F15;&#x7528;&#x7684;&#x8D44;&#x6E90;&#x6216;&#x662F;&#x8D44;&#x6E90;&#x5C5E;&#x6027;&#x53D1;&#x751F;&#x53D8;&#x66F4;&#x65F6;&#x66FF;&#x6362;&#x58F0;&#x660E;&#x8BE5;&#x5757;&#x7684;&#x7236;&#x8D44;&#x6E90;&#xFF0C;&#x503C;&#x4E3A;&#x4E00;&#x4E2A;&#x5305;&#x542B;&#x4E86;&#x6258;&#x7BA1;&#x8D44;&#x6E90;&#x3001;&#x5B9E;&#x4F8B;&#x6216;&#x662F;&#x5B9E;&#x4F8B;&#x5C5E;&#x6027;&#x5F15;&#x7528;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5217;&#x8868;&#x3002;&#x5F53;&#x58F0;&#x660E;&#x8BE5;&#x5757;&#x7684;&#x8D44;&#x6E90;&#x58F0;&#x660E;&#x4E86; <code>count</code> &#x6216;&#x662F; <code>for_each</code> &#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5728;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x4F7F;&#x7528; <code>count.index</code> &#x6216;&#x662F; <code>each.key</code> &#x6765;&#x6307;&#x5B9A;&#x5F15;&#x7528;&#x5B9E;&#x4F8B;&#x7684;&#x5E8F;&#x53F7;&#x3002;</li>
</ul>
<p><code>replace_triggered_by</code> &#x53EF;&#x4EE5;&#x5728;&#x4EE5;&#x4E0B;&#x51E0;&#x79CD;&#x573A;&#x666F;&#x4E2D;&#x4F7F;&#x7528;&#xFF1A;</p>
<ul>
<li>&#x5982;&#x679C;&#x8868;&#x8FBE;&#x5F0F;&#x6307;&#x5411;&#x591A;&#x5B9E;&#x4F8B;&#x7684;&#x8D44;&#x6E90;&#x58F0;&#x660E;&#xFF08;&#x4F8B;&#x5982;&#x58F0;&#x660E;&#x4E86; <code>count</code> &#x6216;&#x662F; <code>for_each</code> &#x7684;&#x8D44;&#x6E90;&#xFF09;&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x7EC4;&#x8D44;&#x6E90;&#x4E2D;&#x4EFB;&#x610F;&#x5B9E;&#x4F8B;&#x53D1;&#x751F;&#x53D8;&#x66F4;&#x6216;&#x88AB;&#x66FF;&#x6362;&#x65F6;&#x90FD;&#x5C06;&#x5F15;&#x53D1;&#x58F0;&#x660E; <code>replace_triggered_by</code> &#x7684;&#x8D44;&#x6E90;&#x88AB;&#x66FF;&#x6362;</li>
<li>&#x5982;&#x679C;&#x8868;&#x8FBE;&#x5F0F;&#x6307;&#x5411;&#x5355;&#x4E2A;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#xFF0C;&#x90A3;&#x4E48;&#x8BE5;&#x5B9E;&#x4F8B;&#x53D1;&#x751F;&#x53D8;&#x66F4;&#x6216;&#x88AB;&#x66FF;&#x6362;&#x65F6;&#x5C06;&#x5F15;&#x53D1;&#x58F0;&#x660E; <code>replace_triggered_by</code> &#x7684;&#x8D44;&#x6E90;&#x88AB;&#x66FF;&#x6362; </li>
<li>&#x5982;&#x679C;&#x8868;&#x8FBE;&#x5F0F;&#x6307;&#x5411;&#x5355;&#x4E2A;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#x7684;&#x5355;&#x4E2A;&#x5C5E;&#x6027;&#xFF0C;&#x90A3;&#x4E48;&#x8BE5;&#x5C5E;&#x6027;&#x503C;&#x7684;&#x4EFB;&#x4F55;&#x53D8;&#x5316;&#x90FD;&#x5C06;&#x5F15;&#x53D1;&#x58F0;&#x660E; <code>replace_triggered_by</code> &#x7684;&#x8D44;&#x6E90;&#x88AB;&#x66FF;&#x6362;</li>
</ul>
<p>&#x6211;&#x4EEC;&#x5728; <code>replace_triggered_by</code> &#x4E2D;&#x53EA;&#x80FD;&#x5F15;&#x7528;&#x6258;&#x7BA1;&#x8D44;&#x6E90;&#x3002;&#x8FD9;&#x5141;&#x8BB8;&#x6211;&#x4EEC;&#x5728;&#x4E0D;&#x5F15;&#x53D1;&#x5F3A;&#x5236;&#x66FF;&#x6362;&#x7684;&#x524D;&#x63D0;&#x4E0B;&#x4FEE;&#x6539;&#x8FD9;&#x4E9B;&#x8868;&#x8FBE;&#x5F0F;&#x3002;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_appautoscaling_target&quot;</span></span> <span class="token string">&quot;ecs_target&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># ...</span>
  <span class="token keyword">lifecycle</span> <span class="token punctuation">{</span>
    <span class="token property">replace_triggered_by</span> <span class="token punctuation">=</span> <span class="token punctuation">[</span>
      <span class="token comment"># Replace `aws_appautoscaling_target` each time this instance of </span>
      <span class="token comment"># the `aws_ecs_service` is replaced.</span>
      aws_ecs_service.svc.id
    <span class="token punctuation">]</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p><code>lifecycle</code> &#x914D;&#x7F6E;&#x5F71;&#x54CD;&#x4E86; Terraform &#x5982;&#x4F55;&#x6784;&#x5EFA;&#x5E76;&#x904D;&#x5386;&#x4F9D;&#x8D56;&#x56FE;&#x3002;&#x4F5C;&#x4E3A;&#x7ED3;&#x679C;&#xFF0C;<code>lifecycle</code> &#x5185;&#x8D4B;&#x503C;&#x4EC5;&#x652F;&#x6301;&#x5B57;&#x9762;&#x91CF;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x7684;&#x8BA1;&#x7B97;&#x8FC7;&#x7A0B;&#x53D1;&#x751F;&#x5728; Terraform &#x8BA1;&#x7B97;&#x7684;&#x6781;&#x65E9;&#x671F;&#x3002;&#x8FD9;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x4F8B;&#x5982; <code>prevent_destroy</code>&#x3001;<code>create_before_destroy</code> &#x7684;&#x503C;&#x53EA;&#x80FD;&#x662F; <code>true</code> &#x6216;&#x8005; <code>false</code>&#xFF0C;<code>ignore_changes</code>&#x3001;<code>replace_triggered_by</code> &#x7684;&#x5217;&#x8868;&#x5185;&#x53EA;&#x80FD;&#x662F;&#x786C;&#x7F16;&#x7801;&#x7684;&#x5C5E;&#x6027;&#x540D;&#x3002;</p>
<h3 id="precondition-&#x4E0E;-postcondition"><a name="precondition-&#x4E0E;-postcondition" class="anchor-navigation-ex-anchor" href="#precondition-&#x4E0E;-postcondition"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.6.7. Precondition &#x4E0E; Postcondition</h3>
<p>&#x8BF7;&#x6CE8;&#x610F;&#xFF0C;Precondition &#x4E0E; Postcondition &#x662F;&#x4ECE; Terraform v1.2.0 &#x5F00;&#x59CB;&#x88AB;&#x5F15;&#x5165;&#x7684;&#x529F;&#x80FD;&#x3002;</p>
<p>&#x5728; <code>lifecycle</code> &#x5757;&#x4E2D;&#x58F0;&#x660E; <code>precondition</code> &#x4E0E; <code>postcondition</code> &#x5757;&#x53EF;&#x4EE5;&#x4E3A;&#x8D44;&#x6E90;&#x3001;&#x6570;&#x636E;&#x6E90;&#x4EE5;&#x53CA;&#x8F93;&#x51FA;&#x503C;&#x521B;&#x5EFA;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x9A8C;&#x8BC1;&#x89C4;&#x5219;&#x3002;</p>
<p>Terraform &#x5728;&#x8BA1;&#x7B97;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x4E4B;&#x524D;&#x4F1A;&#x9996;&#x5148;&#x68C0;&#x67E5;&#x8BE5;&#x5BF9;&#x8C61;&#x5173;&#x8054;&#x7684; <code>precondition</code>&#xFF0C;&#x5E76;&#x4E14;&#x5728;&#x5BF9;&#x8C61;&#x8BA1;&#x7B97;&#x5B8C;&#x6210;&#x540E;&#x6267;&#x884C; <code>postcondition</code> &#x68C0;&#x67E5;&#x3002;Terraform &#x4F1A;&#x5C3D;&#x53EF;&#x80FD;&#x65E9;&#x5730;&#x6267;&#x884C;&#x81EA;&#x5B9A;&#x4E49;&#x68C0;&#x67E5;&#xFF0C;&#x4F46;&#x5982;&#x679C;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x5305;&#x542B;&#x4E86;&#x53EA;&#x6709;&#x5728; <code>apply</code> &#x9636;&#x6BB5;&#x624D;&#x80FD;&#x77E5;&#x6653;&#x7684;&#x503C;&#xFF0C;&#x90A3;&#x4E48;&#x8BE5;&#x68C0;&#x67E5;&#x4E5F;&#x5C06;&#x88AB;&#x63A8;&#x8FDF;&#x6267;&#x884C;&#x3002;</p>
<p>&#x6BCF;&#x4E00;&#x4E2A; <code>precondition</code> &#x4E0E; <code>postcondition</code> &#x5757;&#x90FD;&#x9700;&#x8981;&#x4E00;&#x4E2A; <code>condition</code> &#x53C2;&#x6570;&#x3002;&#x8BE5;&#x53C2;&#x6570;&#x662F;&#x4E00;&#x4E2A;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x5728;&#x6EE1;&#x8DB3;&#x6761;&#x4EF6;&#x65F6;&#x8FD4;&#x56DE; <code>true</code>&#xFF0C;&#x5426;&#x5219;&#x8FD4;&#x56DE; <code>false</code>&#x3002;&#x8BE5;&#x8868;&#x8FBE;&#x5F0F;&#x53EF;&#x4EE5;&#x5F15;&#x7528;&#x540C;&#x4E00;&#x6A21;&#x5757;&#x5185;&#x7684;&#x4EFB;&#x610F;&#x5176;&#x4ED6;&#x5BF9;&#x8C61;&#xFF0C;&#x53EA;&#x8981;&#x8FD9;&#x79CD;&#x5F15;&#x7528;&#x4E0D;&#x4F1A;&#x4EA7;&#x751F;&#x73AF;&#x4F9D;&#x8D56;&#x3002;&#x5728; <code>postcondition</code> &#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>self</code> &#x5BF9;&#x8C61;&#x5F15;&#x7528;&#x58F0;&#x660E; <code>postcondition</code> &#x7684;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;&#x7684;&#x5C5E;&#x6027;&#x3002;</p>
<p>&#x5982;&#x679C; <code>condition</code> &#x8868;&#x8FBE;&#x5F0F;&#x8BA1;&#x7B97;&#x7ED3;&#x679C;&#x4E3A; <code>false</code>&#xFF0C;Terraform &#x4F1A;&#x751F;&#x6210;&#x4E00;&#x6761;&#x9519;&#x8BEF;&#x4FE1;&#x606F;&#xFF0C;&#x5305;&#x542B;&#x4E86; <code>error_message</code> &#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5185;&#x5BB9;&#x3002;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x58F0;&#x660E;&#x4E86;&#x591A;&#x6761; <code>precondition</code> &#x6216; <code>postcondition</code>&#xFF0C;Terraform &#x4F1A;&#x8FD4;&#x56DE;&#x6240;&#x6709;&#x5931;&#x8D25;&#x6761;&#x4EF6;&#x5BF9;&#x5E94;&#x7684;&#x9519;&#x8BEF;&#x4FE1;&#x606F;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x6F14;&#x793A;&#x4E86;&#x901A;&#x8FC7; <code>postcondition</code> &#x68C0;&#x6D4B;&#x8C03;&#x7528;&#x8005;&#x662F;&#x5426;&#x4E0D;&#x5C0F;&#x5FC3;&#x4F20;&#x5165;&#x4E86;&#x9519;&#x8BEF;&#x7684; AMI &#x53C2;&#x6570;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">data <span class="token type variable">&quot;aws_ami&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">id</span> <span class="token punctuation">=</span> var.aws_ami_id

  <span class="token keyword">lifecycle</span> <span class="token punctuation">{</span>
    <span class="token comment"># The AMI ID must refer to an existing AMI that has the tag &quot;nomad-server&quot;.</span>
    <span class="token keyword">postcondition</span> <span class="token punctuation">{</span>
      <span class="token property">condition</span>     <span class="token punctuation">=</span> self.tags<span class="token punctuation">[</span><span class="token string">&quot;Component&quot;</span><span class="token punctuation">]</span> <span class="token punctuation">=</span><span class="token punctuation">=</span> <span class="token string">&quot;nomad-server&quot;</span>
      <span class="token property">error_message</span> <span class="token punctuation">=</span> <span class="token string">&quot;tags[\&quot;Component\&quot;] must be \&quot;nomad-server\&quot;.&quot;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5728; <code>resource</code> &#x6216; <code>data</code> &#x5757;&#x4E2D;&#x7684; <code>lifecycle</code> &#x5757;&#x53EF;&#x4EE5;&#x540C;&#x65F6;&#x5305;&#x542B; <code>precondition</code> &#x4E0E; <code>postcondition</code> &#x5757;&#x3002;</p>
<ul>
<li>Terraform &#x4F1A;&#x5728;&#x8BA1;&#x7B97;&#x5B8C; <code>count</code> &#x548C; <code>for_each</code> &#x5143;&#x53C2;&#x6570;&#x540E;&#x6267;&#x884C; <code>precondition</code> &#x5757;&#x3002;&#x8FD9;&#x4F7F;&#x5F97; Terraform &#x53EF;&#x4EE5;&#x5BF9;&#x6BCF;&#x4E00;&#x4E2A;&#x5B9E;&#x4F8B;&#x72EC;&#x7ACB;&#x8FDB;&#x884C;&#x68C0;&#x67E5;&#xFF0C;&#x5E76;&#x5141;&#x8BB8;&#x5728;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x4F7F;&#x7528; <code>each.key</code>&#x3001;<code>count.index</code> &#x7B49;&#x3002;Terraform &#x8FD8;&#x4F1A;&#x5728;&#x8BA1;&#x7B97;&#x8D44;&#x6E90;&#x7684;&#x53C2;&#x6570;&#x8868;&#x8FBE;&#x5F0F;&#x4E4B;&#x524D;&#x6267;&#x884C; <code>precondition</code> &#x68C0;&#x67E5;&#x3002;<code>precondition</code> &#x53EF;&#x4EE5;&#x7528;&#x6765;&#x9632;&#x6B62;&#x53C2;&#x6570;&#x8868;&#x8FBE;&#x5F0F;&#x8BA1;&#x7B97;&#x4E2D;&#x7684;&#x9519;&#x8BEF;&#x88AB;&#x6FC0;&#x53D1;&#x3002;</li>
<li>Terraform &#x5728;&#x8BA1;&#x7B97;&#x548C;&#x6267;&#x884C;&#x5BF9;&#x4E00;&#x4E2A;&#x6258;&#x7BA1;&#x8D44;&#x6E90;&#x7684;&#x53D8;&#x66F4;&#x4E4B;&#x540E;&#x6267;&#x884C; <code>postcondition</code> &#x68C0;&#x67E5;&#xFF0C;&#x6216;&#x662F;&#x5728;&#x5B8C;&#x6210;&#x6570;&#x636E;&#x6E90;&#x8BFB;&#x53D6;&#x540E;&#x6267;&#x884C;&#x5B83;&#x5173;&#x8054;&#x7684; <code>postcondition</code> &#x68C0;&#x67E5;&#x3002;<code>postcondition</code> &#x5931;&#x8D25;&#x4F1A;&#x963B;&#x6B62;&#x5176;&#x4ED6;&#x4F9D;&#x8D56;&#x4E8E;&#x6B64;&#x5931;&#x8D25;&#x8D44;&#x6E90;&#x7684;&#x5176;&#x4ED6;&#x8D44;&#x6E90;&#x7684;&#x53D8;&#x66F4;&#x3002;</li>
</ul>
<p>&#x5728;&#x5927;&#x591A;&#x6570;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x5EFA;&#x8BAE;&#x5728;&#x540C;&#x4E00;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x540C;&#x65F6;&#x5305;&#x542B;&#x8868;&#x793A;&#x540C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x7684; <code>data</code> &#x5757;&#x548C; <code>resource</code> &#x5757;&#x3002;&#x8FD9;&#x6837;&#x505A;&#x4F1A;&#x4F7F;&#x5F97; Terraform &#x65E0;&#x6CD5;&#x7406;&#x89E3; <code>data</code> &#x5757;&#x7684;&#x7ED3;&#x679C;&#x4F1A;&#x88AB; <code>resource</code> &#x5757;&#x7684;&#x53D8;&#x66F4;&#x6240;&#x5F71;&#x54CD;&#x3002;&#x7136;&#x800C;&#xFF0C;&#x5F53;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x68C0;&#x67E5;&#x4E00;&#x4E2A; <code>resource</code> &#x5757;&#x7684;&#x7ED3;&#x679C;&#xFF0C;&#x6070;&#x5DE7;&#x8BE5;&#x7ED3;&#x679C;&#x53C8;&#x6CA1;&#x6709;&#x88AB;&#x8D44;&#x6E90;&#x76F4;&#x63A5;&#x8F93;&#x51FA;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>data</code> &#x5757;&#x5E76;&#x5728;&#x5757;&#x4E2D;&#x76F4;&#x63A5;&#x4F7F;&#x7528; <code>postcondition</code> &#x6765;&#x68C0;&#x67E5;&#x8BE5;&#x5BF9;&#x8C61;&#x3002;&#x8FD9;&#x7B49;&#x4E8E;&#x544A;&#x8BC9; Terraform &#x8BE5; <code>data</code> &#x5757;&#x662F;&#x7528;&#x6765;&#x68C0;&#x67E5;&#x5176;&#x4ED6;&#x4EC0;&#x4E48;&#x5730;&#x65B9;&#x5B9A;&#x4E49;&#x7684;&#x5BF9;&#x8C61;&#x7684;&#xFF0C;&#x4ECE;&#x800C;&#x5141;&#x8BB8; Terraform &#x4EE5;&#x6B63;&#x786E;&#x7684;&#x987A;&#x5E8F;&#x6267;&#x884C;&#x64CD;&#x4F5C;&#x3002;</p>
<h3 id="provisioner-&#x548C;-connection"><a name="provisioner-&#x548C;-connection" class="anchor-navigation-ex-anchor" href="#provisioner-&#x548C;-connection"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.6.8. provisioner &#x548C; connection</h3>
<p>&#x67D0;&#x4E9B;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x5BF9;&#x8C61;&#x9700;&#x8981;&#x5728;&#x521B;&#x5EFA;&#x540E;&#x6267;&#x884C;&#x7279;&#x5B9A;&#x7684;&#x64CD;&#x4F5C;&#x624D;&#x80FD;&#x6B63;&#x5F0F;&#x5DE5;&#x4F5C;&#x3002;&#x6BD4;&#x5982;&#x8BF4;&#xFF0C;&#x4E3B;&#x673A;&#x5B9E;&#x4F8B;&#x5FC5;&#x987B;&#x5728;&#x4E0A;&#x4F20;&#x4E86;&#x914D;&#x7F6E;&#x6216;&#x662F;&#x7531;&#x914D;&#x7F6E;&#x7BA1;&#x7406;&#x5DE5;&#x5177;&#x521D;&#x59CB;&#x5316;&#x4E4B;&#x540E;&#x624D;&#x80FD;&#x6B63;&#x5E38;&#x5DE5;&#x4F5C;&#x3002;</p>
<p>&#x50CF;&#x8FD9;&#x6837;&#x521B;&#x5EFA;&#x540E;&#x6267;&#x884C;&#x7684;&#x64CD;&#x4F5C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x9884;&#x7F6E;&#x5668;(Provisioner)&#x3002;&#x9884;&#x7F6E;&#x5668;&#x662F;&#x7531; Terraform &#x6240;&#x63D0;&#x4F9B;&#x7684;&#x53E6;&#x4E00;&#x7EC4;&#x63D2;&#x4EF6;&#xFF0C;&#x6BCF;&#x79CD;&#x9884;&#x7F6E;&#x5668;&#x53EF;&#x4EE5;&#x5728;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x521B;&#x5EFA;&#x540E;&#x6267;&#x884C;&#x4E0D;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x64CD;&#x4F5C;&#x3002;</p>
<p>&#x4F7F;&#x7528;&#x9884;&#x7F6E;&#x5668;&#x9700;&#x8981;&#x8282;&#x5236;&#xFF0C;&#x56E0;&#x4E3A;&#x4ED6;&#x4EEC;&#x91C7;&#x53D6;&#x7684;&#x64CD;&#x4F5C;&#x5E76;&#x975E; Terraform &#x58F0;&#x660E;&#x5F0F;&#x7684;&#x98CE;&#x683C;&#xFF0C;&#x6240;&#x4EE5; Terraform &#x65E0;&#x6CD5;&#x5BF9;&#x4ED6;&#x4EEC;&#x6267;&#x884C;&#x7684;&#x53D8;&#x66F4;&#x8FDB;&#x884C;&#x5EFA;&#x6A21;&#x548C;&#x4FDD;&#x5B58;&#x3002;</p>
<p>&#x9884;&#x7F6E;&#x5668;&#x4E5F;&#x53EF;&#x4EE5;&#x58F0;&#x660E;&#x4E3A;&#x8D44;&#x6E90;&#x9500;&#x6BC1;&#x524D;&#x6267;&#x884C;&#xFF0C;&#x4F46;&#x4F1A;&#x6709;&#x4E00;&#x4E9B;&#x9650;&#x5236;&#x3002;</p>
<p>&#x4F5C;&#x4E3A;&#x5143;&#x53C2;&#x6570;&#xFF0C;<code>provisioner</code> &#x548C; <code>connection</code> &#x53EF;&#x4EE5;&#x58F0;&#x660E;&#x5728;&#x4EFB;&#x610F;&#x7C7B;&#x578B;&#x7684; <code>resource</code> &#x5757;&#x5185;&#x3002;</p>
<p>&#x4E3E;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;web&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># ...</span>

  <span class="token keyword">provisioner<span class="token type variable"> &quot;file&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">source</span>       <span class="token punctuation">=</span> <span class="token string">&quot;conf/myapp.conf&quot;</span>
  <span class="token property">destination</span>  <span class="token punctuation">=</span> <span class="token string">&quot;/etc/myapp.conf&quot;</span>

    <span class="token keyword">connection</span> <span class="token punctuation">{</span>
      <span class="token property">type</span>     <span class="token punctuation">=</span> <span class="token string">&quot;ssh&quot;</span>
      <span class="token property">user</span>     <span class="token punctuation">=</span> <span class="token string">&quot;root&quot;</span>
      <span class="token property">password</span> <span class="token punctuation">=</span> var.root_password
      <span class="token property">host</span>     <span class="token punctuation">=</span> self.public_ip
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x5728; <code>aws_instance</code> &#x4E2D;&#x5B9A;&#x4E49;&#x4E86;&#x7C7B;&#x578B;&#x4E3A; <code>file</code> &#x7684;&#x9884;&#x7F6E;&#x5668;&#xFF0C;&#x8BE5;&#x9884;&#x7F6E;&#x5668;&#x53EF;&#x4EE5;&#x672C;&#x673A;&#x6587;&#x4EF6;&#x6216;&#x6587;&#x4EF6;&#x5939;&#x62F7;&#x8D1D;&#x5230;&#x76EE;&#x6807;&#x673A;&#x5668;&#x7684;&#x6307;&#x5B9A;&#x8DEF;&#x5F84;&#x4E0B;&#x3002;&#x6211;&#x4EEC;&#x5728;&#x9884;&#x7F6E;&#x5668;&#x5185;&#x90E8;&#x5B9A;&#x4E49;&#x4E86;<code>connection</code>&#x5757;&#xFF0C;&#x7C7B;&#x578B;&#x662F;<code>ssh</code>&#x3002;&#x6211;&#x4EEC;&#x5BF9;<code>connection</code>&#x7684;<code>host</code>&#x8D4B;&#x503C;<code>self.public_ip</code>&#xFF0C;&#x5728;&#x8FD9;&#x91CC;<code>self</code>&#x4EE3;&#x8868;&#x9884;&#x7F6E;&#x5668;&#x6240;&#x5728;&#x7684;&#x6BCD;&#x5757;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;<code>aws_instance.web</code>&#xFF0C;&#x6240;&#x4EE5;<code>self.public_ip</code>&#x4EE3;&#x8868;&#x7740;<code>aws_instance.web.public_ip</code>&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x521B;&#x5EFA;&#x51FA;&#x6765;&#x7684;&#x4E3B;&#x673A;&#x7684;&#x516C;&#x7F51;ip&#x3002;</p>
<p><code>file</code> &#x7C7B;&#x578B;&#x9884;&#x7F6E;&#x5668;&#x652F;&#x6301; <code>ssh</code> &#x548C; <code>winrm</code> &#x4E24;&#x79CD;&#x7C7B;&#x578B;&#x7684; <code>connection</code>&#x3002;</p>
<p>&#x9884;&#x7F6E;&#x5668;&#x6839;&#x636E;&#x8FD0;&#x884C;&#x7684;&#x65F6;&#x673A;&#x5206;&#x4E3A;&#x4E24;&#x79CD;&#x7C7B;&#x578B;&#xFF0C;&#x521B;&#x5EFA;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#x4EE5;&#x53CA;&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#x3002;</p>
<h2 id="&#x521B;&#x5EFA;&#x65F6;&#x9884;&#x7F6E;&#x5668;"><a name="&#x521B;&#x5EFA;&#x65F6;&#x9884;&#x7F6E;&#x5668;" class="anchor-navigation-ex-anchor" href="#&#x521B;&#x5EFA;&#x65F6;&#x9884;&#x7F6E;&#x5668;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.7. &#x521B;&#x5EFA;&#x65F6;&#x9884;&#x7F6E;&#x5668;</h2>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x521B;&#x5EFA;&#x65F6;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x4F1A;&#x8FD0;&#x884C;&#x9884;&#x7F6E;&#x5668;&#xFF0C;&#x5728;&#x5BF9;&#x8C61;&#x66F4;&#x65B0;&#x3001;&#x9500;&#x6BC1;&#x65F6;&#x5219;&#x4E0D;&#x4F1A;&#x8FD0;&#x884C;&#x3002;&#x9884;&#x7F6E;&#x5668;&#x7684;&#x9ED8;&#x8BA4;&#x884C;&#x4E3A;&#x662F;&#x4E3A;&#x4E86;&#x5F15;&#x5BFC;&#x4E00;&#x4E2A;&#x7CFB;&#x7EDF;&#x3002;</p>
<p>&#x5982;&#x679C;&#x521B;&#x5EFA;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#x5931;&#x8D25;&#x4E86;&#xFF0C;&#x90A3;&#x4E48;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x4F1A;&#x88AB;&#x6807;&#x8BB0;&#x6C61;&#x70B9;(&#x6211;&#x4EEC;&#x5C06;&#x5728;&#x4ECB;&#x7ECD; <code>terraform taint</code> &#x547D;&#x4EE4;&#x65F6;&#x8BE6;&#x7EC6;&#x4ECB;&#x7ECD;)&#x3002;&#x4E00;&#x4E2A;&#x88AB;&#x6807;&#x8BB0;&#x6C61;&#x70B9;&#x7684;&#x8D44;&#x6E90;&#x5728;&#x4E0B;&#x6B21;&#x6267;&#x884C; <code>terraform apply</code> &#x547D;&#x4EE4;&#x65F6;&#x4F1A;&#x88AB;&#x9500;&#x6BC1;&#x5E76;&#x91CD;&#x5EFA;&#x3002;Terraform &#x7684;&#x8FD9;&#x79CD;&#x8BBE;&#x8BA1;&#x662F;&#x56E0;&#x4E3A;&#x5F53;&#x9884;&#x7F6E;&#x5668;&#x8FD0;&#x884C;&#x5931;&#x8D25;&#x65F6;&#x6807;&#x5FD7;&#x7740;&#x8D44;&#x6E90;&#x5904;&#x4E8E;&#x534A;&#x5C31;&#x7EEA;&#x7684;&#x72B6;&#x6001;&#x3002;&#x7531;&#x4E8E; Terraform &#x65E0;&#x6CD5;&#x8861;&#x91CF;&#x9884;&#x7F6E;&#x5668;&#x7684;&#x884C;&#x4E3A;&#xFF0C;&#x6240;&#x4EE5;&#x552F;&#x4E00;&#x80FD;&#x591F;&#x5B8C;&#x5168;&#x786E;&#x4FDD;&#x8D44;&#x6E90;&#x88AB;&#x6B63;&#x786E;&#x521D;&#x59CB;&#x5316;&#x7684;&#x65B9;&#x5F0F;&#x5C31;&#x662F;&#x5220;&#x9664;&#x91CD;&#x5EFA;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8BBE;&#x7F6E; <code>on_failure</code> &#x53C2;&#x6570;&#x6765;&#x6539;&#x53D8;&#x8FD9;&#x79CD;&#x884C;&#x4E3A;&#x3002;</p>
<h2 id="&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;"><a name="&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;" class="anchor-navigation-ex-anchor" href="#&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.8. &#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;</h2>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x8BBE;&#x7F6E;&#x9884;&#x7F6E;&#x5668;&#x7684; <code>when</code> &#x53C2;&#x6570;&#x4E3A; <code>destroy</code>&#xFF0C;&#x90A3;&#x4E48;&#x9884;&#x7F6E;&#x5668;&#x4F1A;&#x5728;&#x8D44;&#x6E90;&#x88AB;&#x9500;&#x6BC1;&#x65F6;&#x6267;&#x884C;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;web&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># ...</span>

  <span class="token keyword">provisioner<span class="token type variable"> &quot;local-exec&quot; </span></span><span class="token punctuation">{</span>
    <span class="token property">when</span>    <span class="token punctuation">=</span> destroy
    <span class="token property">command</span> <span class="token punctuation">=</span> <span class="token string">&quot;echo &apos;Destroy-time provisioner&apos;&quot;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#x5728;&#x8D44;&#x6E90;&#x88AB;&#x5B9E;&#x9645;&#x9500;&#x6BC1;&#x524D;&#x8FD0;&#x884C;&#x3002;&#x5982;&#x679C;&#x8FD0;&#x884C;&#x5931;&#x8D25;&#xFF0C;Terraform &#x4F1A;&#x62A5;&#x9519;&#xFF0C;&#x5E76;&#x5728;&#x4E0B;&#x6B21;&#x8FD0;&#x884C; <code>terraform apply</code> &#x64CD;&#x4F5C;&#x65F6;&#x91CD;&#x65B0;&#x6267;&#x884C;&#x9884;&#x7F6E;&#x5668;&#x3002;&#x5728;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x9700;&#x8981;&#x4ED4;&#x7EC6;&#x5173;&#x6CE8;&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#x4EE5;&#x4F7F;&#x4E4B;&#x80FD;&#x591F;&#x5B89;&#x5168;&#x5730;&#x53CD;&#x590D;&#x6267;&#x884C;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#x4E0D;&#x4F1A;&#x5728; <code>resource</code> &#x5757;&#x914D;&#x7F6E;&#x4E86; <code>create_before_destroy = true</code> &#x65F6;&#x8FD0;&#x884C;&#x3002;</p>
<p>&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#x53EA;&#x6709;&#x5728;&#x5B58;&#x5728;&#x4E8E;&#x4EE3;&#x7801;&#x4E2D;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x624D;&#x4F1A;&#x5728;&#x9500;&#x6BC1;&#x65F6;&#x88AB;&#x6267;&#x884C;&#x3002;&#x5982;&#x679C;&#x4E00;&#x4E2A; <code>resource</code> &#x5757;&#x8FDE;&#x5E26;&#x5185;&#x90E8;&#x7684;&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#x5757;&#x4E00;&#x8D77;&#x88AB;&#x4ECE;&#x4EE3;&#x7801;&#x4E2D;&#x5220;&#x9664;&#xFF0C;&#x90A3;&#x4E48;&#x88AB;&#x5220;&#x9664;&#x7684;&#x9884;&#x7F6E;&#x5668;&#x5728;&#x8D44;&#x6E90;&#x88AB;&#x9500;&#x6BC1;&#x65F6;<strong>&#x4E0D;&#x4F1A;</strong>&#x88AB;&#x6267;&#x884C;&#x3002;&#x8981;&#x89E3;&#x51B3;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x591A;&#x4E2A;&#x6B65;&#x9AA4;&#x6765;&#x7ED5;&#x8FC7;&#x8FD9;&#x4E2A;&#x9650;&#x5236;&#xFF1A;</p>
<ul>
<li>&#x4FEE;&#x6539;&#x8D44;&#x6E90;&#x58F0;&#x660E;&#x4EE3;&#x7801;&#xFF0C;&#x6DFB;&#x52A0; <code>count = 0</code> &#x53C2;&#x6570;</li>
<li>&#x6267;&#x884C; <code>terraform apply</code>&#xFF0C;&#x8FD0;&#x884C;&#x5220;&#x9664;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#xFF0C;&#x7136;&#x540E;&#x5220;&#x9664;&#x8D44;&#x6E90;&#x5B9E;&#x4F8B;</li>
<li>&#x5220;&#x9664; <code>resource</code> &#x5757;</li>
<li>&#x91CD;&#x65B0;&#x6267;&#x884C; <code>terraform apply</code>&#xFF0C;&#x6B64;&#x65F6;&#x5E94;&#x8BE5;&#x4E0D;&#x4F1A;&#x6709;&#x4EFB;&#x4F55;&#x53D8;&#x66F4;&#x9700;&#x8981;&#x6267;&#x884C;</li>
</ul>
<p>&#x8BE5;&#x9650;&#x5236;&#x5728;&#x672A;&#x6765;&#x5C06;&#x4F1A;&#x5F97;&#x5230;&#x89E3;&#x51B3;&#xFF0C;&#x4F46;&#x76EE;&#x524D;&#x6765;&#x8BF4;&#x6211;&#x4EEC;&#x5FC5;&#x987B;&#x8282;&#x5236;&#x4F7F;&#x7528;&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x4E00;&#x4E2A;&#x88AB;&#x6807;&#x8BB0;&#x6C61;&#x70B9;&#x7684; <code>resource</code> &#x5757;&#x5185;&#x7684;&#x9500;&#x6BC1;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#x4E0D;&#x4F1A;&#x88AB;&#x6267;&#x884C;&#x3002;&#x8FD9;&#x5305;&#x62EC;&#x4E86;&#x56E0;&#x4E3A;&#x521B;&#x5EFA;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#x5931;&#x8D25;&#x6216;&#x662F;&#x624B;&#x52A8;&#x4F7F;&#x7528; <code>terraform taint</code> &#x547D;&#x4EE4;&#x6807;&#x8BB0;&#x6C61;&#x70B9;&#x7684;&#x8D44;&#x6E90;&#x3002;</p>
<h2 id="&#x9884;&#x7F6E;&#x5668;&#x5931;&#x8D25;&#x884C;&#x4E3A;"><a name="&#x9884;&#x7F6E;&#x5668;&#x5931;&#x8D25;&#x884C;&#x4E3A;" class="anchor-navigation-ex-anchor" href="#&#x9884;&#x7F6E;&#x5668;&#x5931;&#x8D25;&#x884C;&#x4E3A;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.9. &#x9884;&#x7F6E;&#x5668;&#x5931;&#x8D25;&#x884C;&#x4E3A;</h2>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x9884;&#x7F6E;&#x5668;&#x8FD0;&#x884C;&#x5931;&#x8D25;&#x4F1A;&#x5BFC;&#x81F4;<code>terraform apply</code>&#x6267;&#x884C;&#x5931;&#x8D25;&#x3002;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8BBE;&#x7F6E;<code>on_failure</code>&#x53C2;&#x6570;&#x6765;&#x6539;&#x53D8;&#x8FD9;&#x4E00;&#x884C;&#x4E3A;&#x3002;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x7684;&#x503C;&#x4E3A;&#xFF1A;</p>
<ul>
<li><code>continue</code>&#xFF1A;&#x5FFD;&#x89C6;&#x9519;&#x8BEF;&#xFF0C;&#x7EE7;&#x7EED;&#x6267;&#x884C;&#x521B;&#x5EFA;&#x6216;&#x662F;&#x9500;&#x6BC1;</li>
<li><code>fail</code>&#xFF1A;&#x62A5;&#x9519;&#x5E76;&#x7EC8;&#x6B62;&#x6267;&#x884C;&#x53D8;&#x66F4;(&#x8FD9;&#x662F;&#x9ED8;&#x8BA4;&#x884C;&#x4E3A;)&#x3002;&#x5982;&#x679C;&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x521B;&#x5EFA;&#x65F6;&#x9884;&#x7F6E;&#x5668;&#xFF0C;&#x5219;&#x5728;&#x5BF9;&#x5E94;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x4E0A;&#x6807;&#x8BB0;&#x6C61;&#x70B9;</li>
</ul>
<p>&#x6837;&#x4F8B;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;web&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># ...</span>

  <span class="token keyword">provisioner<span class="token type variable"> &quot;local-exec&quot; </span></span><span class="token punctuation">{</span>
    <span class="token property">command</span>    <span class="token punctuation">=</span> <span class="token string">&quot;echo The server&apos;s IP address is <span class="token interpolation"><span class="token punctuation">$</span><span class="token punctuation">{</span><span class="token keyword">self</span><span class="token punctuation">.</span><span class="token type variable">private_ip</span><span class="token punctuation">}</span></span>&quot;</span>
    <span class="token property">on_failure</span> <span class="token punctuation">=</span> continue
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h2 id="&#x672C;&#x5730;&#x8D44;&#x6E90;"><a name="&#x672C;&#x5730;&#x8D44;&#x6E90;" class="anchor-navigation-ex-anchor" href="#&#x672C;&#x5730;&#x8D44;&#x6E90;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.10. &#x672C;&#x5730;&#x8D44;&#x6E90;</h2>
<p>&#x867D;&#x7136;&#x5927;&#x90E8;&#x5206;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x90FD;&#x5BF9;&#x5E94;&#x7684;&#x662F;&#x901A;&#x8FC7;&#x8FDC;&#x7A0B;&#x57FA;&#x7840;&#x8BBE;&#x65BD; API &#x63A7;&#x5236;&#x7684;&#x4E00;&#x4E2A;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#xFF0C;&#x4F46;&#x4E5F;&#x6709;&#x4E00;&#x4E9B;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x4ED6;&#x4EEC;&#x53EA;&#x5B58;&#x5728;&#x4E8E; Terraform &#x8FDB;&#x7A0B;&#x81EA;&#x8EAB;&#x5185;&#x90E8;&#xFF0C;&#x7528;&#x6765;&#x8BA1;&#x7B97;&#x751F;&#x6210;&#x67D0;&#x4E9B;&#x7ED3;&#x679C;&#xFF0C;&#x5E76;&#x5C06;&#x8FD9;&#x4E9B;&#x7ED3;&#x679C;&#x4FDD;&#x5B58;&#x5728;&#x72B6;&#x6001;&#x4E2D;&#x4EE5;&#x5907;&#x65E5;&#x540E;&#x4F7F;&#x7528;&#x3002;</p>
<p>&#x6BD4;&#x5982;&#x8BF4;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x7528; <code>tls_private_key</code> &#x751F;&#x6210;&#x516C;&#x79C1;&#x94A5;&#xFF0C;&#x7528; <code>tls_self_signed_cert</code> &#x751F;&#x6210;&#x81EA;&#x7B7E;&#x540D;&#x8BC1;&#x4E66;&#xFF0C;&#x6216;&#x8005;&#x662F;&#x7528; <code>random_id</code> &#x751F;&#x6210;&#x968F;&#x673A; id&#x3002;&#x867D;&#x4E0D;&#x50CF;&#x5176;&#x4ED6;&#x201C;&#x771F;&#x5B9E;&#x201D;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x5BF9;&#x8C61;&#x90A3;&#x822C;&#x91CD;&#x8981;&#xFF0C;&#x4F46;&#x8FD9;&#x4E9B;&#x672C;&#x5730;&#x8D44;&#x6E90;&#x4E5F;&#x53EF;&#x4EE5;&#x6210;&#x4E3A;&#x8FDE;&#x63A5;&#x5176;&#x4ED6;&#x8D44;&#x6E90;&#x6709;&#x7528;&#x7684;&#x9ECF;&#x5408;&#x5242;&#x3002;</p>
<p>&#x672C;&#x5730;&#x8D44;&#x6E90;&#x7684;&#x884C;&#x4E3A;&#x4E0E;&#x5176;&#x4ED6;&#x7C7B;&#x578B;&#x8D44;&#x6E90;&#x662F;&#x4E00;&#x81F4;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x4ED6;&#x4EEC;&#x7684;&#x7ED3;&#x679C;&#x6570;&#x636E;&#x4EC5;&#x5B58;&#x5728;&#x4E8E; Terraform &#x72B6;&#x6001;&#x6587;&#x4EF6;&#x4E2D;&#x3002;&#x201C;&#x9500;&#x6BC1;&#x201D;&#x8FD9;&#x79CD;&#x8D44;&#x6E90;&#x53EA;&#x662F;&#x5C06;&#x7ED3;&#x679C;&#x6570;&#x636E;&#x4ECE;&#x72B6;&#x6001;&#x4E2D;&#x5220;&#x9664;&#x3002;</p>
<h2 id="&#x64CD;&#x4F5C;&#x8D85;&#x65F6;&#x8BBE;&#x7F6E;"><a name="&#x64CD;&#x4F5C;&#x8D85;&#x65F6;&#x8BBE;&#x7F6E;" class="anchor-navigation-ex-anchor" href="#&#x64CD;&#x4F5C;&#x8D85;&#x65F6;&#x8BBE;&#x7F6E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6.1.11. &#x64CD;&#x4F5C;&#x8D85;&#x65F6;&#x8BBE;&#x7F6E;</h2>
<p>&#x6709;&#x4E9B;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x63D0;&#x4F9B;&#x4E86;&#x7279;&#x6B8A;&#x7684; <code>timeouts</code> &#x5185;&#x5D4C;&#x5757;&#x53C2;&#x6570;&#xFF0C;&#x5B83;&#x5141;&#x8BB8;&#x6211;&#x4EEC;&#x914D;&#x7F6E;&#x6211;&#x4EEC;&#x5141;&#x8BB8;&#x64CD;&#x4F5C;&#x6301;&#x7EED;&#x591A;&#x957F;&#x65F6;&#x95F4;&#xFF0C;&#x8D85;&#x65F6;&#x5C06;&#x88AB;&#x8BA4;&#x5B9A;&#x4E3A;&#x5931;&#x8D25;&#x3002;&#x6BD4;&#x5982;&#x8BF4;&#xFF0C;<code>aws_db_instance</code> &#x8D44;&#x6E90;&#x5141;&#x8BB8;&#x6211;&#x4EEC;&#x5206;&#x522B;&#x4E3A; <code>create</code>&#xFF0C;<code>update</code>&#xFF0C;<code>delete</code> &#x64CD;&#x4F5C;&#x8BBE;&#x7F6E;&#x8D85;&#x65F6;&#x65F6;&#x95F4;&#x3002;</p>
<p>&#x8D85;&#x65F6;&#x5B8C;&#x5168;&#x7531;&#x8D44;&#x6E90;&#x5BF9;&#x5E94;&#x7684; Provider &#x6765;&#x5904;&#x7406;&#xFF0C;&#x4F46;&#x652F;&#x6301;&#x8D85;&#x65F6;&#x8BBE;&#x7F6E;&#x7684; Provider &#x4E00;&#x822C;&#x90FD;&#x9075;&#x5FAA;&#x76F8;&#x540C;&#x7684;&#x4F20;&#x7EDF;&#xFF0C;&#x90A3;&#x5C31;&#x662F;&#x7531;&#x4E00;&#x4E2A;&#x540D;&#x4E3A; <code>timeouts</code> &#x7684;&#x5185;&#x5D4C;&#x5757;&#x53C2;&#x6570;&#x5B9A;&#x4E49;&#x8D85;&#x65F6;&#x8BBE;&#x7F6E;&#xFF0C;<code>timeouts</code> &#x5757;&#x5185;&#x53EF;&#x4EE5;&#x5206;&#x522B;&#x8BBE;&#x7F6E;&#x4E0D;&#x540C;&#x64CD;&#x4F5C;&#x7684;&#x8D85;&#x65F6;&#x65F6;&#x95F4;&#x3002;&#x8D85;&#x65F6;&#x65F6;&#x95F4;&#x7531; <code>string</code> &#x63CF;&#x8FF0;&#xFF0C;&#x6BD4;&#x5982; <code>&quot;60m&quot;</code> &#x4EE3;&#x8868; 60 &#x5206;&#x949F;&#xFF0C;<code>&quot;10s&quot;</code> &#x4EE3;&#x8868; 10 &#x79D2;&#xFF0C;<code>&quot;2h&quot;</code> &#x4EE3;&#x8868; 2 &#x5C0F;&#x65F6;&#x3002;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_db_instance&quot;</span></span> <span class="token string">&quot;example&quot;</span> <span class="token punctuation">{</span>
  <span class="token comment"># ...</span>

  <span class="token keyword">timeouts</span> <span class="token punctuation">{</span>
    <span class="token property">create</span> <span class="token punctuation">=</span> <span class="token string">&quot;60m&quot;</span>
    <span class="token property">delete</span> <span class="token punctuation">=</span> <span class="token string">&quot;2h&quot;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x53EF;&#x914D;&#x7F6E;&#x8D85;&#x65F6;&#x7684;&#x64CD;&#x4F5C;&#x7C7B;&#x522B;&#x7531;&#x6BCF;&#x79CD;&#x652F;&#x6301;&#x8D85;&#x65F6;&#x8BBE;&#x5B9A;&#x7684;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x81EA;&#x884C;&#x51B3;&#x5B9A;&#x3002;&#x5927;&#x90E8;&#x5206;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x4E0D;&#x652F;&#x6301;&#x8BBE;&#x7F6E;&#x8D85;&#x65F6;&#x3002;&#x4F7F;&#x7528;&#x8D85;&#x65F6;&#x524D;&#x8BF7;&#x5148;&#x67E5;&#x9605;&#x76F8;&#x5173;&#x6587;&#x6863;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="3.5.局部值.html" class="navigation navigation-prev " aria-label="Previous page: 局部值">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="3.7.数据源.html" class="navigation navigation-next " aria-label="Next page: 数据源">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"资源","level":"1.4.6","depth":2,"next":{"title":"数据源","level":"1.4.7","depth":2,"path":"3.7.数据源.md","ref":"./3.7.数据源.md","articles":[]},"previous":{"title":"局部值","level":"1.4.5","depth":2,"path":"3.5.局部值.md","ref":"./3.5.局部值.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-highlight","prism","prism-themes","fontsettings","sharing","-lunr","-search","search-pro","livereload","image-captions","sitemap-general","anchor-navigation-ex"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"css":["prism-themes/themes/prism-vsc-dark-plus.css"],"lang":{"shell":"bash","cmd":"bash"}},"livereload":{},"search-pro":{},"sitemap-general":{"prefix":"https://lonegunmanb.github.io/introduction-terraform/"},"fontsettings":{"family":"sans","size":2,"theme":"white"},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"prism-themes":{},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":true,"google":false,"instapaper":false,"twitter":true,"vk":false,"weibo":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"image-captions":{"caption":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","variable_name":"_pictures"}},"theme":"default","author":"大可不加冰","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"_pictures":[{"backlink":"index.html#fig1.1.1","level":"1.1","list_caption":"Figure: Nomad、Consul、Vault、Terraform 组成的 HashiStack","alt":"Nomad、Consul、Vault、Terraform 组成的 HashiStack","nro":1,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-13/1605243540985-image.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Nomad、Consul、Vault、Terraform 组成的 HashiStack","attributes":{},"skip":false,"key":"1.1.1"},{"backlink":"index.html#fig1.1.2","level":"1.1","list_caption":"Figure: Terraform 著名教材《Terraform Up & Running》，建议直接阅读第二版","alt":"Terraform 著名教材《Terraform Up & Running》，建议直接阅读第二版","nro":2,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-12-23/1608689176373-image.png","index":2,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Terraform 著名教材《Terraform Up & Running》，建议直接阅读第二版","attributes":{},"skip":false,"key":"1.1.2"},{"backlink":"./2.1.Terraform基础概念——Provider.html#fig1.3.1.1","level":"1.3.1","list_caption":"Figure: Terraform通过RPC调用插件，插件代码通过调用SDK操作远程资源","alt":"Terraform通过RPC调用插件，插件代码通过调用SDK操作远程资源","nro":3,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-16/1605496195438-image.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Terraform通过RPC调用插件，插件代码通过调用SDK操作远程资源","attributes":{},"skip":false,"key":"1.3.1.1"},{"backlink":"./2.1.Terraform基础概念——Provider.html#fig1.3.1.2","level":"1.3.1","list_caption":"Figure: registry.terraform.io上的插件页面","alt":"registry.terraform.io上的插件页面","nro":4,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-19/1605799350775-image.png","index":2,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"registry.terraform.io上的插件页面","attributes":{},"skip":false,"key":"1.3.1.2"},{"backlink":"./2.1.Terraform基础概念——Provider.html#fig1.3.1.3","level":"1.3.1","list_caption":"Figure: registry.terraform.io的搜索页面","alt":"registry.terraform.io的搜索页面","nro":5,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-16/1605498907942-image.png","index":3,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"registry.terraform.io的搜索页面","attributes":{},"skip":false,"key":"1.3.1.3"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.1","level":"1.3.2","list_caption":"Figure: Consul的GUI界面","alt":"Consul的GUI界面","nro":6,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220224455.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Consul的GUI界面","attributes":{},"skip":false,"key":"1.3.2.1"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.2","level":"1.3.2","list_caption":"Figure: Consul 中可以看到名为 `localstack-aws` 的键","alt":"Consul 中可以看到名为 `localstack-aws` 的键","nro":7,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220230042.png","index":2,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Consul 中可以看到名为 `localstack-aws` 的键","attributes":{},"skip":false,"key":"1.3.2.2"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.3","level":"1.3.2","list_caption":"Figure: 键的内容","alt":"键的内容","nro":8,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220230136.png","index":3,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"键的内容","attributes":{},"skip":false,"key":"1.3.2.3"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.4","level":"1.3.2","list_caption":"Figure: 键依然存在","alt":"键依然存在","nro":9,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220230312.png","index":4,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"键依然存在","attributes":{},"skip":false,"key":"1.3.2.4"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.5","level":"1.3.2","list_caption":"Figure: 内容已被清空","alt":"内容已被清空","nro":10,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220230350.png","index":5,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"内容已被清空","attributes":{},"skip":false,"key":"1.3.2.5"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.6","level":"1.3.2","list_caption":"Figure: 多了一个同名的文件夹","alt":"多了一个同名的文件夹","nro":11,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225100309.png","index":6,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"多了一个同名的文件夹","attributes":{},"skip":false,"key":"1.3.2.6"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.7","level":"1.3.2","list_caption":"Figure: localstack-aws 文件夹内部","alt":"localstack-aws 文件夹内部","nro":12,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225100354.png","index":7,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"localstack-aws 文件夹内部","attributes":{},"skip":false,"key":"1.3.2.7"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.8","level":"1.3.2","list_caption":"Figure: `.lock` 内容","alt":"`.lock` 内容","nro":13,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225180803.png","index":8,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"`.lock` 内容","attributes":{},"skip":false,"key":"1.3.2.8"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.9","level":"1.3.2","list_caption":"Figure: `.lockinfo` 内容","alt":"`.lockinfo` 内容","nro":14,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225180852.png","index":9,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"`.lockinfo` 内容","attributes":{},"skip":false,"key":"1.3.2.9"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.10","level":"1.3.2","list_caption":"Figure: 重新访问Consul","alt":"重新访问Consul","nro":15,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225101100.png","index":10,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"重新访问Consul","attributes":{},"skip":false,"key":"1.3.2.10"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.11","level":"1.3.2","list_caption":"Figure: 将代码复制到不同的文件夹中保存","alt":"将代码复制到不同的文件夹中保存","nro":16,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-17/1605571444613-image.png","index":11,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"将代码复制到不同的文件夹中保存","attributes":{},"skip":false,"key":"1.3.2.11"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.12","level":"1.3.2","list_caption":"Figure: 重新访问 Consul，目前有一个键","alt":"重新访问 Consul，目前有一个键","nro":17,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225174932.png","index":12,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"重新访问 Consul，目前有一个键","attributes":{},"skip":false,"key":"1.3.2.12"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.13","level":"1.3.2","list_caption":"Figure: Consul 中多了一个 `localstack-aws-env:feature1`","alt":"Consul 中多了一个 `localstack-aws-env:feature1`","nro":18,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225175538.png","index":13,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Consul 中多了一个 `localstack-aws-env:feature1`","attributes":{},"skip":false,"key":"1.3.2.13"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.14","level":"1.3.2","list_caption":"Figure: 此时 `localstack-aws-env:feature1` 的内容","alt":"此时 `localstack-aws-env:feature1` 的内容","nro":19,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225175806.png","index":14,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"此时 `localstack-aws-env:feature1` 的内容","attributes":{},"skip":false,"key":"1.3.2.14"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.15","level":"1.3.2","list_caption":"Figure: `localstack-aws-env:feature1` 被删除了","alt":"`localstack-aws-env:feature1` 被删除了","nro":20,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225180126.png","index":15,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"`localstack-aws-env:feature1` 被删除了","attributes":{},"skip":false,"key":"1.3.2.15"},{"backlink":"./5.10.graph.html#fig1.6.10.1","level":"1.6.10","list_caption":"Figure: 生成的依赖图","alt":"生成的依赖图","nro":21,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-25/1606272727693-image.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"生成的依赖图","attributes":{},"skip":false,"key":"1.6.10.1"},{"backlink":"8.CloudPosse最佳实践.html#fig1.9.1","level":"1.9","list_caption":"Figure: Terraform 输出值的命名要对称","alt":"Terraform 输出值的命名要对称","nro":22,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2021-11-28/1638086002974-image.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Terraform 输出值的命名要对称","attributes":{},"skip":false,"key":"1.9.1"}]},"title":"《Terraform入门教程》","gitbook":"*"},"file":{"path":"3.6.资源.md","mtime":"2024-06-10T13:57:50.234Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2024-06-24T12:39:39.308Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    

    </body>
</html>

